Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is mapbox-android sdk not resolving from build.gradle?

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'
    }
}
like image 699
glutz Avatar asked Oct 23 '25 18:10

glutz


2 Answers

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

like image 161
langsmith Avatar answered Oct 26 '25 07:10

langsmith


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'] ?: ""
      }
    }
  }
}
like image 41
Martin Zeitler Avatar answered Oct 26 '25 07:10

Martin Zeitler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!