roro roor
roro roor

Reputation: 147

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

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
}

Upvotes: 8

Views: 23044

Answers (10)

Djoxy
Djoxy

Reputation: 54

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 "".

Upvotes: 0

Mohammad Bilal Akbar
Mohammad Bilal Akbar

Reputation: 169

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.

Upvotes: 0

faisal ur rehman
faisal ur rehman

Reputation: 356

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'] ?: ""
        }
    }
}

Upvotes: 1

Ahmed Mohammed
Ahmed Mohammed

Reputation: 537

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.

Upvotes: 3

DIGITII
DIGITII

Reputation: 31

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'] ?: ""
                    }
                }
            }
        }
    }
}

Upvotes: 3

Etherlind
Etherlind

Reputation: 311

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'

Upvotes: 1

Mark Darwin Villarta
Mark Darwin Villarta

Reputation: 41

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'
    }

Upvotes: 4

LuiRe
LuiRe

Reputation: 161

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.

Upvotes: 16

Moritz
Moritz

Reputation: 1790

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'] ?: ""
      }
    }
  }
}

Upvotes: 10

Martin Zeitler
Martin Zeitler

Reputation: 76799

How about trying a version, which actually exists?

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.7'

Upvotes: 1

Related Questions