我正试图在这里设置基本教程,但我被Android Studio中的错误所阻挡:https://docs.mapbox.com/android/maps/overview/#install-the-maps-sdk
错误1:当我同步build.gradle时看到:
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.4.0.然后,我添加了推荐的排除项,但仍然得到错误。
错误2:它说要从命令行运行gradle,但也没有找到。
下面是我的build.gradle的相关部分:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.4.0'
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:9.4.0'){
exclude group: 'group_name', module: 'module_name'
}
}发布于 2020-09-16 01:30:18
您可以删除以下行
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:9.4.0'){
exclude group: 'group_name', module: 'module_name'
}您可能遗漏了https://docs.mapbox.com/android/maps/overview/#add-the-dependency的第5步中看到的maven块。确保您添加了它。
另外,您是否创建了具有正确作用域的秘密令牌?请参阅https://docs.mapbox.com/android/maps/overview/#configure-credentials上的第二个要点(A secret access token with the...)
发布于 2020-09-16 06:11:11
您需要配置MapBox存储库:
allprojects {
repositories {
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
username = 'mapbox'
// Use the secret token you stored in gradle.properties as the password
password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
}
}
}
}发布于 2020-11-05 16:17:27
在我的情况下
MAPBOX_DOWNLOADS_TOKEN="PASTE_YOUR_SECRET_TOKEN_HERE" instead of MAPBOX_DOWNLOADS_TOKEN=PASTE_YOUR_SECRET_TOKEN_HERE.刚刚删除了引号,它worked.Just尝试这个。
https://stackoverflow.com/questions/63904628
复制相似问题