Reputation: 4809
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
Download Token is generated from MapBox site with DOWNLOAD:READ permission, as they mentioned in the documentation and it was starting with sk.
MAPBOX_DOWNLOADS_TOKEN=sk.sdjshdjshdj.....etc
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.
I don't know what's wrong. Thanks in advance.
Upvotes: 4
Views: 2317
Reputation: 1
Here is how my build.gradle project level looks like:
allprojects {
repositories {
google()
mavenCentral()
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
}
}
}
build.gradle app level:
implementation('com.mapbox.maps:android:10.3.0')
And I am providing the view with the token:
<com.mapbox.maps.MapView xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
mapbox:mapbox_resourcesAccessToken="@string/map_box_access_token" />
Upvotes: -1
Reputation: 66
I was struggling with this for two days. Version 9.2.6 works with the same documentation. Also make sure you change your settings.gradle to PREFER_SETTINGS. Add maven {url 'https://mapbox.bintray.com/mapbox' } to your project level gradle under maven central. your MAPBOX_DOWNLOADS_TOKEN will start with "sk" instead of "pk". When downloading your private key, check the DOWNLOADS:READ
Upvotes: 2