Reputation: 1959
I'm trying to setup the basic tutorial here but i am blocked by errors in Android Studio: https://docs.mapbox.com/android/maps/overview/#install-the-maps-sdk
Error 1: seen when i Sync the build.gradle:
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.4.0.
I then added the recommended exclude items and still get the error.
Error 2: It says to run gradle from the command line but that is not found either.
Here's the relevant part of my 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'
}
}
Upvotes: 4
Views: 8137
Reputation: 1701
Well i know it is too late but still thought to write an answer as i got same error
here is solution
in your app level gradle file , replace as mentioned below
From
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'
}
To
implementation 'com.mapbox.maps:android:10.11.0'
For Android Studio less than Arctic Fox (2020.3.1) and Gradle less than v6.0: Open up your project-level build.gradle file, and add the code below to declare the endpoint in the repositories block:
allprojects {
repositories {
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'] ?: ""
}
}
}
}
Android Studio Arctic Fox (2020.3.1) or later and Gradle v6.0 or later: You may need to make these declarations in your settings.gradle file instead. If you see build errors with the build.gradle process described above, then instead declare the Mapbox's Maven repository in your settings.gradle file like below:
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
}
}
}
}
For more details , you can refer this link https://docs.mapbox.com/android/maps/guides/install/
Upvotes: 0
Reputation: 1335
i also faced this issue , isolved it by using an old version of mapbox the new version has some issue connecting to the mapbox server
try using this or some other version
dependencies{
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.0.0'
}
allprojects {
repositories {
...
mavenCentral()
}
}
Upvotes: 1
Reputation: 2146
In my case
MAPBOX_DOWNLOADS_TOKEN="PASTE_YOUR_SECRET_TOKEN_HERE" instead of MAPBOX_DOWNLOADS_TOKEN=PASTE_YOUR_SECRET_TOKEN_HERE.
Just removed quotes and it worked.Just try this.
Upvotes: 1
Reputation: 76799
You need to configure the MapBox repository:
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'] ?: ""
}
}
}
}
Upvotes: 1
Reputation: 1959
i had changed the username to my own name. apparently it should remain as "mapbox".
Upvotes: 0
Reputation: 2546
You can remove the following line
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:9.4.0'){
exclude group: 'group_name', module: 'module_name'
}
You're probably missing the maven
block as seen in step #5 of https://docs.mapbox.com/android/maps/overview/#add-the-dependency. Make sure you add it.
Also, have you created a secret token with the right scope? See the second bullet point (A secret access token with the...
) at https://docs.mapbox.com/android/maps/overview/#configure-credentials
Upvotes: 1