输入图片描述
build.gradle(工程)文件如下
buildscript {存储库{
google()
mavenCentral()
maven { url 'https://mapbox.bintray.com/mapbox' }
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = "mapbox"
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
}
}build.gradle(module)文件如下
implementation 'com.mapbox.navigator:mapbox-navigation-native:7.0.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.42.6'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v9:0.12.0'
将类路径更改为以下版本:
build.gradle
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
}
在gradle-wrapper中。属性,将distributionUrl更改为以下版本:
gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip
最后,在构建中为mapbox SDK添加以下依赖文件。Gradle如下:
build.gradle
dependencies {
//mapbox
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.42.6'
//FusedLocationProviderClient
implementation "com.google.android.gms:play-services-location:18.0.0"
}