Android Studio Mapbox未解析依赖项android SDK

mzsu5hc0  于 2022-11-25  发布在  Android
关注(0)|答案(1)|浏览(186)

我试图使一个Android应用程序与Mapbox SDK在android工作室,只是为了熟悉我运行通过this教程.
然而,我得到了依赖性错误。其他帖子建议弹回9. 5. 0,但也有同样的问题。
项目构建.gradle:

allprojects {
    repositories {
        google()
        maven {
            url 'https://api.mapbox.com/downloads/v2/releases/maven'
            authentication {
                basic(BasicAuthentication)
            }
            credentials {
                username = 'mapbox'
                password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""
            }
        }
    }
}

其中我的私人访问令牌在一个名为www.example.com的文本文件中gradle.properties,名为MAPBOX_DOWNLOADS_TOKEN。
我得到的错误是:

Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/mapboxsdk/mapbox-android-telemetry/6.2.2/mapbox-android-telemetry-6.2.2.pom'. Received status code 401 from server: Unauthorized

我会很感激任何帮助。

vaj7vani

vaj7vani1#

尝试将其添加到设置中。gradle

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    google()
    mavenCentral()
    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 = ['Token'] ?: ""

        }
    }
}

}

相关问题