I am using the package @homee/react-native-mapbox-navigation for a turn by turn navigation. beneath you can see the depencies and versions:
"dependencies": {
"@homee/react-native-mapbox-navigation": "^1.1.0",
"react": "17.0.1",
"react-native": "0.64.2"
}
The package works fine when I set the property shouldSimulateRoute={true}. When I set it to false or remove it the app crashes on a androidphone. And on my simulator its gives me a wrong location.
This is my gradle.build:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = "mapbox"
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
in my AndroidManifest.xml file I added this line of code
<meta-data android:name="MAPBOX_ACCESS_TOKEN" android:value="code_here" />
And in my MainApplication.java I imported this:
import com.homee.mapboxnavigation.MapboxNavigationPackage;
The strange thing is that it all works fine when shouldSimulate is true when I set is to false as the default should be it doesn`t work anymore.
Does someone know how to fix this?
Thx!
I have solved the problem. It looks like if you turn off the shouldSimulateRoute property and set it to false you have to use the users current location, so you cant hardcode it. this helped for me!