无法在我的 android 应用程序中安装地图框,从服务器接收到状态代码 403:禁止访问
Failed to install map box in my android app with Received status code 403 from server: Forbidden
无法解析配置“:app:debugRuntimeClasspath”的所有文件。
Could not resolve com.mapbox.navigator:mapbox-navigation-native:7.0.0.
Required by:
project :app > com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.42.6 > com.mapbox.mapboxsdk:mapbox-android-navigation:0.42.6
> Could not resolve com.mapbox.navigator:mapbox-navigation-native:7.0.0.
> Could not get resource 'https://mapbox.bintray.com/mapbox/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom'.
> Could not GET 'https://mapbox.bintray.com/mapbox/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom'. Received status code 403 from server: Forbidden
> Could not resolve com.mapbox.navigator:mapbox-navigation-native:7.0.0.
> Could not get resource 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom'.
> Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom'. Received status code 403 from server: Forbidden
问题:
您没有下载 mapbox 依赖项的访问权限,这需要您的 mapbox 帐户的有效令牌。
解法:
首先,您需要拥有一个具有下载权限的 mapbox 访问令牌:
转到 https://account.mapbox.com/access-tokens/create 并使用 Downloads:READ
创建访问令牌
您需要在项目级别 gradle 指定 mapbox 令牌,将您的令牌添加到 gradle.properties
android.useAndroidX=true
android.enableJetifier=true
MAPBOX_DOWNLOADS_TOKEN=yourMapBoxKey
请注意,您需要在您的令牌上启用 Downloads:Read 范围,否则您将在构建项目时收到 403: forbidden
和你的 build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
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'] ?: ""
}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
希望这可以帮助解决问题。
参考:
https://githubmemory.com/repo/eopeter/flutter_mapbox_navigation/issues/126
基于@Moulaye 的回答,对我来说,我将新的存储库 URL 添加到我的构建脚本存储库中的 Maven,但它没有用,我仍然遇到 401 未经授权的错误,即使适当的令牌。我所做的也是向我的 Allprojects 存储库添加身份验证,就像在提到 maven 存储库的任何地方添加身份验证一样。像这样:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
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'] ?: ""
}
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
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'] ?: ""
}
}
}
}
两次。对于出于某种奇怪原因可能遇到类似问题的任何人。确保从 mapbox 生成一个新的下载令牌并选中 DOWNLOADS:READ
选项。
无法解析配置“:app:debugRuntimeClasspath”的所有文件。
Could not resolve com.mapbox.navigator:mapbox-navigation-native:7.0.0. Required by: project :app > com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.42.6 > com.mapbox.mapboxsdk:mapbox-android-navigation:0.42.6 > Could not resolve com.mapbox.navigator:mapbox-navigation-native:7.0.0. > Could not get resource 'https://mapbox.bintray.com/mapbox/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom'. > Could not GET 'https://mapbox.bintray.com/mapbox/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom'. Received status code 403 from server: Forbidden > Could not resolve com.mapbox.navigator:mapbox-navigation-native:7.0.0. > Could not get resource 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom'. > Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/navigator/mapbox-navigation-native/7.0.0/mapbox-navigation-native-7.0.0.pom'. Received status code 403 from server: Forbidden
问题:
您没有下载 mapbox 依赖项的访问权限,这需要您的 mapbox 帐户的有效令牌。
解法:
首先,您需要拥有一个具有下载权限的 mapbox 访问令牌:
转到 https://account.mapbox.com/access-tokens/create 并使用 Downloads:READ
您需要在项目级别 gradle 指定 mapbox 令牌,将您的令牌添加到 gradle.properties
android.useAndroidX=true
android.enableJetifier=true
MAPBOX_DOWNLOADS_TOKEN=yourMapBoxKey
请注意,您需要在您的令牌上启用 Downloads:Read 范围,否则您将在构建项目时收到 403: forbidden
和你的 build.gradle
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
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'] ?: ""
}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
希望这可以帮助解决问题。
参考: https://githubmemory.com/repo/eopeter/flutter_mapbox_navigation/issues/126
基于@Moulaye 的回答,对我来说,我将新的存储库 URL 添加到我的构建脚本存储库中的 Maven,但它没有用,我仍然遇到 401 未经授权的错误,即使适当的令牌。我所做的也是向我的 Allprojects 存储库添加身份验证,就像在提到 maven 存储库的任何地方添加身份验证一样。像这样:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
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'] ?: ""
}
}
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
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'] ?: ""
}
}
}
}
两次。对于出于某种奇怪原因可能遇到类似问题的任何人。确保从 mapbox 生成一个新的下载令牌并选中 DOWNLOADS:READ
选项。