Home > Blockchain >  Could not resolve mapbox-android-sdk
Could not resolve mapbox-android-sdk

Time:03-12

I am trying to add latest version of Map box, but its failing. I have followed MapBox Documentation

secret token in gradle.properties file:

MAPBOX_DOWNLOADS_TOKEN=MY_SECRET_MAPBOX_ACCESS_TOKEN_IN_PAIN_TEXT_WITHOUT_QUOTES

My settings.gradle File.

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
        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
            }
        }
        maven { url "https://maven.google.com" }
        maven { url 'https://jitpack.io' }
   }
}

app level gradle file

dependencies {
  //OTHER DEPENDENCIES....
  implementation 'com.mapbox.maps:android:10.3.0'
}

After Syncing Gradle Files.

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:10.3.0.
Show Details
Affected Modules: app

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:10.3.0.
Show Details
Affected Modules: app

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:10.3.0.
Show Details
Affected Modules: app

I have checked below answers, but not working.

  1. How to solve : Failed to resolve: com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0
  2. Why is mapbox-android sdk not resolving from build.gradle?

I don't know what's wrong. Thanks in advance.

CodePudding user response:

I faced the same issue. The fix was generating a private key instead of a public one from your Map Box account. Therefore, your MAPBOX_DOWNLOADS_TOKEN will start with "sk" instead of "pk". Also make sure when you generate your private key to check downloads:read and to name your key.

CodePudding user response:

I am facing the same issue, I have done everything mentioned in the main documentation, forums. I believe the issue is coming for me because of the new android studio update where we have to put stuff in settings.gradle and the repository that I cloned had everything in build.gradle. Still, I am not sure. Did you find a solution?

  • Related