我遵循了https://docs.mapbox.com/android/maps/guides/install/ 上的指南,除了我無法選擇gradle.properties存盤在settings.gradle. 安裝指南中顯示的方法對我不起作用。
這是我的settings.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 = System.getenv("MAPBOX_DOWNLOADS_TOKEN")
}
}
jcenter() // Warning: this repository is going to shut down soon
}
}
rootProject.name = "MyApp Name"
include ':app'
這是我的gradle.properties:
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
MAPBOX_DOWNLOADS_TOKEN=this_is_my_secret_access_token
我可能做錯了什么?
uj5u.com熱心網友回復:
閱讀 gradle 檔案后,我發現 mapbox 安裝指南做錯的事情是在gradle.properties. 您需要將其指定為系統屬性(請參閱https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_system_properties),因此基本上您要做的就是更改
MAPBOX_DOWNLOADS_TOKEN=this_is_my_secret_access_token
在
systemProp.MAPBOX_DOWNLOADS_TOKEN=this_is_my_secret_access_token
現在移動到settings.gradle檔案并更改行
password = System.getenv("MAPBOX_DOWNLOADS_TOKEN")
和
password = System.properties["MAPBOX_DOWNLOADS_TOKEN"]
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/390023.html
標籤:安卓 安卓工作室 等级 地图框 mapbox-android
