Reputation: 21
Correct me if i'm wrong. I'm using mapbox api especially for navigation, now i'm confused and stopped because I can't import the API. I have followed documents from Mapbox itself but I still can't. Sorry for my bad english, i still learn :)
This my build.gradle(app)
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 30 buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.kks.treking"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
repositories {
mavenCentral()
maven { url 'https://mapbox.bintray.com/mapbox' }
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
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.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//Google Authentication
implementation 'com.google.firebase:firebase-auth:19.3.1'
implementation 'com.google.firebase:firebase-database:19.3.0'
implementation 'com.google.android.gms:play-services-location:17.1.0'
//Mapbox
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.1.0'
implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:9.1.0') {
exclude group: 'group_name', module: 'module_name'
}
implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:5.1.0'
implementation "com.mapbox.navigation:ui:1.1.0"
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.google.android.material:material:1.3.0-alpha03'
//noinspection GradleDependency
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"}
And i got this error : Could not GET 'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/navigation/ui/1.1.0/ui-1.1.0.pom'. Received status code 403 from server: Forbidden Disable Gradle 'offline mode' and sync project
Upvotes: 0
Views: 1666
Reputation: 1790
Starting with Mapbox Navigation SDK version > 1.0 ( you are implementing com.mapbox.navigation:ui:1.1.0
), the way to access the Maven repository to download the SDK libraries has changed.
You now need to create a secret access token and use it to access the maven repo, where the libraries are located.
Please also see the official documentation:
https://docs.mapbox.com/android/maps/overview/#configure-credentials
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: 1