首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >导入Mapbox Direction API失败

导入Mapbox Direction API失败
EN

Stack Overflow用户
提问于 2020-11-07 07:49:06
回答 1查看 892关注 0票数 0

如果我错了,请纠正我。我使用mapbox API专门用于导航,现在我感到困惑和停止,因为我不能导入api。我已经阅读了Mapbox本身的文档,但我仍然不能。对不起,我的英语很差,我仍然在学习:)

这是我的build.gradle(应用程序)

应用插件:'com.android.application‘应用插件:'kotlin- android’应用插件:'kotlin-android-extensions‘android{ compileSdkVersion 30 buildToolsVersion "29.0.3“

代码语言:javascript
复制
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
}

}

依赖项{实现包含(目录:'libs',fileTree:'*.jar')

代码语言:javascript
复制
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"}

我得到了这样的错误:无法获取'https://api.mapbox.com/downloads/v2/releases/maven/com/mapbox/navigation/ui/1.1.0/ui-1.1.0.pom'。从服务器收到状态代码403 :禁止禁用Gradle‘离线模式’和同步项目

EN

回答 1

Stack Overflow用户

发布于 2020-11-09 19:54:01

从Mapbox Navigation SDK version > 1.0 (您正在实现com.mapbox.navigation:ui:1.1.0 )开始,访问Maven存储库以下载SDK库的方式已经改变。

现在,您需要创建一个秘密访问令牌,并使用它来访问maven存储库。

另请参阅官方文档:

https://docs.mapbox.com/android/maps/overview/#configure-credentials

您的模块级build.gradle应包含以下内容:

代码语言:javascript
复制
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'] ?: ""
      }
    }
  }
}

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64723046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档