Frank Kai Hei Chan
Frank Kai Hei Chan

Reputation: 1

(Android-Mapbox)Failed to resolve: com.mapbox.navigation:android:2.3.0

I am trying the implement the navigation API of Mapbox into my android application. However, I have encountered the following issue:

Failed to resolve: com.mapbox.navigation:android:2.3.0

May I have your advise for my case please? Thanks.

https://docs.mapbox.com/android/navigation/guides/get-started/install/

Referring to the installation guide, I have already created both public token and secret token(with DOWNLOAD:READ scope checked) and updated the build.gradle(both project and module levels), gradle.properties and the string.xml accordingly, but the implementation did not complete successfully.

Best Regards,

Frank

My Android Studio Version Android Studio Arctic Fox | 2020.3.1 Patch 4

The followings are the sections extracted from my project gradles:

build.gradle(project level)

    buildscript {
        repositories {
            google()
            mavenCentral()
            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'] ?: ""
                }
            }
        }
        dependencies {
            classpath "com.android.tools.build:gradle:7.0.4"
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            maven { url "https://jitpack.io" }
            maven { url 'https://mapbox.bintray.com/mapbox' }
        }
    }

    task clean(type: Delete) {
        delete rootProject.buildDir
    }

build.gradle(module level)

    plugins {
        id 'com.android.application'
    }

    android {
        compileSdk 32

        defaultConfig {
            applicationId "com.xxx.main"
            minSdk 21
            targetSdk 32
            versionCode 1
            versionName "1.0"

            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }

        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }

    dependencies {

        implementation 'androidx.appcompat:appcompat:1.4.1'
        ...
        implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.0'
        implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:7.0.0'
        implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
        implementation "com.mapbox.navigation:android:2.3.0"
        ...
    }

gradle.properties

    MAPBOX_DOWNLOADS_TOKEN=sk.xxxx

string.xml

    <string name="mapbox_access_token">pk.xxxx</string>

Upvotes: 0

Views: 949

Answers (1)

Koch
Koch

Reputation: 594

i just installed mapbox-navigation and this is what my settings look like

Follow these updates :

#1 your build.gradle(project level) becomes

  buildscript {
    repositories {
        google()
        mavenCentral()
      
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}



task clean(type: Delete) {
    delete rootProject.buildDir
}

your build.gradle(module level) is fine

#2 add this below line to your settings.gradle , right above the property rootProject.name = "your-app-name"

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
    google()
    mavenCentral()
    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
        }
    }
}}

Upvotes: 0

Related Questions