How to solve : Failed to resolve: com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0
Asked Answered
S

10

8

I face this problem when trying to use mapbox in Android studio
Failed to resolve: com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0

what is the problem?

my build.gradle dependencies


dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0'
}

my build.gradle project

buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"
    }
}

allprojects {
    repositories {
  google()
        jcenter()
        maven { url 'https://mapbox.bintray.com/mapbox' }

    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
Splitting answered 8/11, 2020 at 13:43 Comment(0)
F
1

How about trying a version, which actually exists?

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.7'
Fester answered 8/11, 2020 at 21:24 Comment(2)
This is an outdated version. Please see my response below on how to solve this problem.Overspill
Just came across that there are 2 branches that are both under development as it seems. The branch using the old way to access the maven repo (8.x) and the branch using the new way (> 9.4). Still please see my response below on how to use the latest release.Overspill
B
15

it's just badly explained. you have to make a private token. public token does not work. when you create a token there is a field with "Read:Download" just mark it and generate your token. This token should work.

Bryology answered 5/2, 2021 at 20:12 Comment(0)
O
9

Version 9.5.0 (and 9.6.0) also exists (See release notes here: https://github.com/mapbox/mapbox-gl-native-android/blob/main/CHANGELOG.md). It is just that the way to access the Maven repository has changed with Mapbox Maps SDK > v9.4.0.

I would discourage you from using an outdated version like mapbox-android-sdk:8.6.7, but go for com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0.

The new way to access the mave repo is documented here: https://docs.mapbox.com/android/maps/overview/#configure-credentials

You now need to create a secret access token and use it to access the maven repo, where the libraries are located. Your module level build.gradle should contain this:

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'] ?: ""
      }
    }
  }
}
Overspill answered 9/11, 2020 at 11:38 Comment(8)
it gives me this error "Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0. "Splitting
can you show your module level build.gradle please?Overspill
I have exactly the same issue. I am also following this documentation. Getting the same error @roro roor mentioned. Could it be, that the error occurs because of the mismatching Gradle dependencies, mentioned in the noted in step 6?Batavia
Looks like it IS a scopes issue. Create a token with Downloads:Read scope should make it workFriulian
The link to the documentation seems to be outdated unfortunatelyEpanorthosis
This didn't work for me. Still can't resolve Mapbox sdk.Tiana
Be sure you set MAPBOX_DOWNLOADS_TOKEN=sk, not pk!Viglione
@AxesGrinds I have the same issues, even though I followed all answers here... Funny enough downgrading the version to implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.7' helps.Sheared
J
4

Just use this safe version and it will work on your gradle.

implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.0'){
        exclude group: 'group_name', module: 'module_name'
    }
Judge answered 7/6, 2021 at 15:4 Comment(0)
E
3

Found Solution by generating private key as pointed out in previous answers, and finding an actual version on maven central, neither 9.7 nor 10 was on the maven central repository at the time of writing, using version 9.2 found here

https://mvnrepository.com/artifact/com.mapbox.mapboxsdk/mapbox-android-sdk

Edit: Was able to use 9.7.0 mapbox by changing settings.gradle entry

repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

to

repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)

and build.gradle to add mavenCentral() and google() to allprojects repositories

allprojects {
    repositories {
        google()
        mavenCentral()
        
        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'] ?: ""
                    }
                }
            }
        }
    }
}
Elute answered 15/10, 2021 at 11:35 Comment(0)
E
3

screenshot

The default token Mapbox provides you is what I think you're using, you need to create a new private token and check this permission DOWNLOAD:READ then it should work.

I created a new token and named it first in my case, you can call it anything.

Erlanger answered 28/10, 2021 at 12:45 Comment(1)
This is solution, as default token is bad one for building android app (expo android also).Disbursement
F
1

How about trying a version, which actually exists?

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.7'
Fester answered 8/11, 2020 at 21:24 Comment(2)
This is an outdated version. Please see my response below on how to solve this problem.Overspill
Just came across that there are 2 branches that are both under development as it seems. The branch using the old way to access the maven repo (8.x) and the branch using the new way (> 9.4). Still please see my response below on how to use the latest release.Overspill
I
1

The only way got my project to finally work is by looking for some pointers in the project attached here: https://github.com/mapbox/mapbox-maps-android/issues/614#issue-988592394 It uses com.mapbox.maps:android:10.0.0-rc.3 and actually works on my machine.

To make my own project work, I had to change settings.gradle from this:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}
rootProject.name = "Mapbox Map"
include ':app'

to this:

rootProject.name = "Mapbox Map"
include ':app'
Institutionalism answered 21/9, 2021 at 8:32 Comment(0)
F
1

You should remove this line : maven{ url 'https://mapbox.bintray.com/mapbox' }

 repositories {
    google()
    jcenter()
    mavenCentral()
    /**
    if you using => maven { url 'https://mapbox.bintray.com/mapbox' }
     so remove this line because mapbox remove repository from https://mapbox.bintray.com/mapbox
    * */
    maven { url "https://oss.sonatype.org/content/groups/public/" }
    maven { url 'https://jitpack.io' }
    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'] ?: ""
        }
    }
}
Freytag answered 6/1, 2022 at 6:49 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Racing
K
0

You can find documentation of Mapbox GL for android here: https://docs.mapbox.com/android/maps/guides/install/.

As said by the mapbox_gl plugin developers, this is community driven not an official Mapbox product.

So, do only the https://docs.mapbox.com/android/maps/guides/install/#configure-credentials part of the documentation for the flutter android project.

  • Create a secret access token with the Downloads:Read scope.

  • Configure your secret token in android/gradle.properties as MAPBOX_DOWNLOADS_TOKEN=YOUR_SECRET_MAPBOX_ACCESS_TOKEN

  • Configure permissions in app/source/main/AndroidManifest.xml as:

    <!-- Always include this permission -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    
    <!-- Include only if your app benefits from precise location access. -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    
  • Keep in mind to provide the same secret key in the accessToken property of the MapboxMap widget in your project.

Kwa answered 2/4, 2023 at 10:49 Comment(1)
Actually it is issue with Mapbox. Default token is not working, you need to generate new one with other privileges. I have extended for all, then is started work.Disbursement
P
0

The problem is due the credentials; just replace the password from :

password = MAPBOX_DOWNLOADS_TOKEN or

password = project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?: ""

To:

password = "Your Token"

and make sure the Token is between double quotes "".

Placeeda answered 11/4, 2023 at 1:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.