ror*_*oor 2 android build.gradle mapbox-android
我在 Android Studio 中尝试使用 mapbox 时遇到这个问题
无法解决:com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0
问题是什么?
我的 build.gradle 依赖项
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0'
}
Run Code Online (Sandbox Code Playgroud)
我的 build.gradle 项目
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://mapbox.bintray.com/mapbox' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
版本 9.5.0(和 9.6.0)也存在(请参阅此处的发行说明:https : //github.com/mapbox/mapbox-gl-native-android/blob/main/CHANGELOG.md)。只是 Mapbox Maps SDK > v9.4.0 更改了访问 Maven 存储库的方式。
我会劝阻你不要使用过时的版本,比如mapbox-android-sdk:8.6.7,但是去com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0.
此处记录了访问 mave 存储库的新方法:https ://docs.mapbox.com/android/maps/overview/#configure-credentials
您现在需要创建一个秘密访问令牌并使用它来访问库所在的 maven 存储库。您的模块级别 build.gradle 应包含以下内容:
allprojects {
repositories {
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'] ?: ""
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
尝试一个实际存在的版本怎么样?
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.7'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3741 次 |
| 最近记录: |