I'm developing an android application with java and I want to integrate Mapbox, I followed all the documentation here: https://docs.mapbox.com/android/maps/guides/install/
I requested both tokens successfully and added the dependency in the build.gradle
.
dependencies {
implementation ("com.mapbox.maps:android:10.1.0")
}
The problem is when I go to paste the following code into 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 = MAPBOX_DOWNLOADS_TOKEN
}
}
}
}
url and basic are not recognized and I get several errors, in particular:
Unexpected tokens (use ';' to separate expressions on the same line)
Unresolved reference: basic
How can i fix this problem during the installation?
The syntax should look like below, I compiled this with Android Studio Giraffe.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url = uri("https://api.mapbox.com/downloads/v2/releases/maven")
authentication {
create<BasicAuthentication>("basic")
}
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 = MAPBOX_DOWNLOADS_TOKEN
}
}
}
}