0

我正在使用包@homee/react-native-mapbox-navigation 进行逐个导航。下面你可以看到依赖和版本:

  "dependencies": {
    "@homee/react-native-mapbox-navigation": "^1.1.0",
    "react": "17.0.1",
    "react-native": "0.64.2"
  }

当我设置属性 shouldSimulateRoute={true} 时,包工作正常。当我将其设置为 false 或将其删除时,应用程序在 androidphone 上崩溃。在我的模拟器上,它给了我一个错误的位置。

这是我的 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' }
    }
  }

在我的 AndroidManifest.xml 文件中,我添加了这行代码

<meta-data android:name="MAPBOX_ACCESS_TOKEN" android:value="code_here" />

在我的 MainApplication.java 中,我导入了这个:

import com.homee.mapboxnavigation.MapboxNavigationPackage;

奇怪的是,当我设置为 false 时 shouldSimulate 为 true 时一切正常,因为默认情况下它应该不再起作用。

有人知道如何解决这个问题吗?

谢谢!

4

1 回答 1

0

我已经解决了这个问题。看起来如果您关闭 shouldSimulateRoute 属性并将其设置为 false 您必须使用用户当前位置,因此您无法对其进行硬编码。这对我有帮助!

于 2021-08-18T12:41:04.743 回答