我正在尝试添加最新版本的Mapbox,但是失败了。
我已经按照MapBox文档的指导进行了操作。
gradle.properties文件中有秘密令牌:
MAPBOX_DOWNLOADS_TOKEN=MY_SECRET_MAPBOX_ACCESS_TOKEN_IN_PAIN_TEXT_WITHOUT_QUOTES
下载令牌是从MapBox网站生成的,具有DOWNLOAD:READ权限,正如他们在文档中提到的一样,它以sk开头。
MAPBOX_DOWNLOADS_TOKEN=sk.sdjshdjshdj.....etc
我的 settings.gradle 文件。
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
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 = MAPBOX_DOWNLOADS_TOKEN
}
}
maven { url "https://maven.google.com" }
maven { url 'https://jitpack.io' }
}
}
应用程序级别的Gradle文件
dependencies {
//OTHER DEPENDENCIES....
implementation 'com.mapbox.maps:android:10.3.0'
}
同步 Gradle 文件后。
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:10.3.0.
Show Details
Affected Modules: app
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:10.3.0.
Show Details
Affected Modules: app
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:10.3.0.
Show Details
Affected Modules: app
我已经查看了下面的答案,但是都没有起作用。 我不知道出了什么问题。谢谢提前。
Mapbox SDK 10.4.0
时也遇到了相同的问题,但是当我尝试下载Mapbox 9.5.0
时一切都正常。 - Ildar Zaripov