How to add below mentioned Mapbox plugins to Android App - android

I happen unable to add LocationLayerPlugin to my Android project and cannot find any documentation to demonstrate how. Also, I can't find NavigationMapRoute inside package com.mapbox.services.android.navigation.ui.v5. Any help, please?
EDIT:
That's my build.gradle below and when typing LocationLayerPlugin, Android Studio cannot resolve it.
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.0#aar') {
transitive = true
}
compile('com.mapbox.mapboxsdk:mapbox-android-services:2.1.3#aar') {
transitive = true
}
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.3.1'

For the LocationLayerPlugin you can use it with two lines of code:
locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine);
locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.TRACKING);
You'll need to make sure to also call the lifecycles in the appropriate methods onStart and onStop. If you are using with navigation and want to use location snapping to the route, you will need to pass in null for the locationEngine and than use forceLocationUpdate inside onProgressChange.
A few examples are available here which show different ways to use the plugin. Documentation will be avliable soon once we release the first final version (currently just producing nightly builds).
For the NavigationMapRoute you'll need to make sure you are using the 0.4.0-snapshot of the Navigation SDK. you'll find it here com.mapbox.services.android.navigation.ui.v5.NavigationMapRoute

Related

How do I implement malloc_trim(0) in ndk toolchains?

Because there is no function malloc_trim in ndk , so I want to find a way to implement malloc_trim(0) in ndk !
A simple definition like the following should suffice:
int malloc_trim(size_t pad) { return 1; }
Better still is to see if whatever library you're compiling has a flag to disable the use of malloc_trim at all.
EDIT: According to this post, jemalloc is the default memory allocator. jemalloc uses mmap by default, not sbrk. Jemalloc automatically returns memory to the OS when certain conditions are met, so I would not bother trying to come up with a useful implementation for malloc_trim.

Why does Android Studio display "only be called from with the same library group" when I remove #SuppressLint("RestrictedApi")?

The Code A is from CameraX project, you can see source code.
Android Studio will display "only be called from with the same library group" when I remove #SuppressLint("RestrictedApi"), you can see Image 1.
Why can't I remove #SuppressLint("RestrictedApi") in Code A ? What deos a restriction API mean?
Code A
#SuppressLint("RestrictedApi")
private fun updateCameraUi() {
...
// Listener for button used to switch cameras
controls.findViewById<ImageButton>(R.id.camera_switch_button).setOnClickListener {
lensFacing = if (CameraX.LensFacing.FRONT == lensFacing) {
CameraX.LensFacing.BACK
} else {
CameraX.LensFacing.FRONT
}
try {
// Only bind use cases if we can query a camera with this orientation
CameraX.getCameraWithLensFacing(lensFacing)
// Unbind all use cases and bind them again with the new lens facing configuration
CameraX.unbindAll()
bindCameraUseCases()
} catch (exc: Exception) {
// Do nothing
}
}
}
Image 1
There have been breaking changes in the library since the tutorial was made.
Reverting the package version to 1.0.0-alpha06, same as the tutorial, solves the problem.
These are issues with the library that don't affect your code.
In several code examples using these APIs there is often a #SuppressLint("RestrictedApi") in the file hiding the warning.
The projects should still compile and run as they should, although you must make sure that you are using the correct dependency version. The APIs are changing quite frequently still, and if you're referencing an example it might be using an older version which has since changed.
Your best bet is to look directly at the source code and if the method you are calling is declared as public then you probably won't have a problem.

'LikeView' has no propType 'RCTFBLikeView.onLayout' of native type 'boolean' if you haven't changed this

LikeView has no propType for native prop RCTFBLikeView.onLayout of native type boolean
If you haven't changed this prop yourself, this usually means that your versions of the native code and JavaScript code are out of sync. Updating both should make this error go away.
Not sure why I am getting this error. I'm not using LikeView at all in the android app. I've tried running npm start --reset-cache.
Also iOS version of the app runs no problem. This only occurs for android.
Any suggestions welcomed.
Thanks!
I figured out that the problem is (as RN points out) a mismatch between the native props and the JS ones on the props that every view uses. Namely:
renderToHardwareTextureAndroid
onLayout
accessibilityLiveRegion
accessibilityComponentType
importantForAccessibility
accessibilityLabel
testID
Since I am not using any of the views that the package uses, namely:
FBLikeView
FBLoginButton
FBSendButton
FBShareButton
I tried to set this props as 'native only', so that they are not bound to the JavaScript side. In every component (in the example, FBShareButton.js), I replaced:
const RCTFBShareButton = requireNativeComponent(
'RCTFBShareButton',
ShareButton,
);
with
const RCTFBShareButton = requireNativeComponent(
'RCTFBShareButton',
ShareButton,
{
nativeOnly: {
onChange: true,
onLayout: true,
testID: true,
importantForAccessibility: true,
accessibilityLiveRegion: true,
accessibilityComponentType: true,
accessibilityLabel: true,
renderToHardwareTextureAndroid: true,
}
},
);
I am now going to check if the views are getting rendered properly and edit my post later, but if you just want to be able to compile your app in order to continue development (as it is my case at the moment), that should let you do so.
Edit
I successfully rendered the LoginButton component using the example in the README with my changes.
Edit 2
I made a pull request with my changes to the package. I don't like the solution, but it might raise FB's attention. In the meantime, you can just use my fork. In your package.json, just replace the fbsdk line with this:
"react-native-fbsdk": "git+https://github.com/motius/react-native-fbsdk.git#fix-views"
This other pull request might be a better solution, actually.
Similar to the solution suggested by #martinarroyo, I figured that it has to do with some components that are not synced between the native code and the js code.
If you are not using these components, instead of adding the nativeOnly property in every js file you use it, I commented out the exports from the react-native-fbsdk index.js as follows:
//native components
// exports.LikeView = require('./FBLikeView');
// exports.LoginButton = require('./FBLoginButton');
// exports.SendButton = require('./FBSendButton');
// exports.ShareButton = require('./FBShareButton');
Obviously this is just a workaround but that should get you through that error
You can downgrade react-native-fbsdk to 0.5.1 to avoid this issue until a fix has been merged into a new version.
So after countless experimentation and banging my head on the table, i think the solution was the versioning of the dependency.
Here's a list of things I attempted and the one I think that resolved the issue is marked with an * because I'm not 100% sure if it was this step that resolved it.
removing node_modules folder and reinstalling it.
doing the react-native-git-upgrade as #matt suggested
reinstalled react-native-fbsdk multiple times following the instructions and double checking the code.
changing the buildToolsVersion & targetSdkVersion to 25.
5**. ultimately running react-native uninstall react-native-fbsdk followed by react-native install react-native-fbsdk#0.5.0.
Note* number 5 was attempted throughout the past two days..yet only now it worked...So I don't know what black magic it is that caused it to work just now...
The issue with number 5 is that prior to yesterday the fbsdk dependency version was 0.5.0 and as of yesterday, it was upgraded to 0.6.0. SO I am not sure why even though I reinstalled it yesterday too, it did not fix the bug.
If someone who is more familiar with this can provide an explanation as to why this occurred I would be inclined to learn.

Android: ContextCompat.getColor(context, R.color.my_color), cannot resolve "getColor"

I know there are several similar questions regarding this has been asked here, however none of the solutions worked for me.
I have just transferred my application from Ecilpse(juno) to Android Studio 1.5.1; and from API 19 to API 23(compileSdkVersion).
Currently I encountered this error whereby "getResources().getColor(R.color.my_color)" is depreciated and cannot be used.
After searching online, I tried to use "ContextCompat.getColor(context, R.color.my_color)" instead. The error lies at the "getColor" part as it says that it cannot be resolved:
The method "ContextCompat" however allow me to use "getDrawable", "getExternalCacheDirs", "getExternalFilesDirs" and "getObbDirs"; just except for "getColor"
I have also ensure that I have these 2 in my app build.gradle (under dependencies{}):
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
Below are my imports for this class (DetailsActivity):
Additionally, I have also tried using "ResourcesCompat" other than "ContextCompat"; and it still did not work out for me.
I am still a beginner at Android Development, working on a school project.
Can anyone kindly provide some suggestions as of what I am doing wrong and point me towards the right direction? Thanks a lot in advance!
You can use this method.
This is the ContextCompat Developer Link from the Support Library:
public static final int getColor(Context context, int id) {
final int version = Build.VERSION.SDK_INT;
if (version >= 23) {
return ContextCompat.getColor(context, id);
} else {
return context.getResources().getColor(id);
}
}
You don't have to use ContextCompat there if you are compiling with an API level greater than 24 as this is only a compatibility feature for early versions. You can also still use Context.getColor() But notice the method signature! If you just want a color in the default theme you only have to provide the int value of its reference: http://developer.android.com/reference/android/content/Context.html#getColor(int)
You are currently trying to access getColor() with two parameters (Color and Theme) which cannot work there as there is no method who supports these parameters. If you remove the 2nd parameter your current solution will work.
But it would be more convenient to use Context or Resources directly and drop the v4 Appcompat reference if you don't need it.
Before to use this method, fist of all add the Dependencies in build.gradle script. Which is as follows:
dependencies {
// other stuff here
compile 'com.android.support:support-v4:23.0.0'
}

How can I make or use a pattern like the newest gmail (for android v5.0)

As we all know,google release the android L,and the gmail went into more beautiful.Now I want to use this pattern like the pic,I searched it everywhere,github included, only to find that nothing.
THX deeply in advanced! Here is the pic:
oh!I'm sorry,I forget to mention that the new refresh layout,could you see the circle within a Curved arrow.swipe the screen down,and it begin to refresh,maybe it's s new swipefreshlayout,thx!
This is the new SwipeRefreshLayout class that is included in the latest support library. The implementation is exactly the same as the old support swipeRefresh layout
Here an overview:
http://www.google.com/design/spec/material-design/introduction.html
Here is explained how to use it: https://developer.android.com/training/material/index.html

Categories

Resources