【问题标题】:Fail to import Mapbox Direction API导入 Mapbox Direction API 失败
【发布时间】:2020-11-06 23:49:06
【问题描述】:

如果我错了,请纠正我。 我正在使用 mapbox api 专门用于导航,现在我很困惑并停止了,因为我无法导入 API。我已经关注了 Mapbox 本身的文档,但我仍然不能。对不起我的英语不好,我还在学习:)

这是我的 build.gradle(app)

应用插件:'com.android.application' 应用插件:'kotlin-android' 应用插件:'kotlin-android-extensions' 安卓 { 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
}

}

依赖{ 实现 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"}

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

【问题讨论】:

    标签: android android-studio mapbox mapbox-android


    【解决方案1】:

    从 Mapbox Navigation SDK 版本 > 1.0(您正在实现 com.mapbox.navigation:ui:1.1.0 )开始,访问 Maven 存储库以下载 SDK 库的方式发生了变化。

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

    另请参阅官方文档:

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

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

    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'] ?: ""
          }
        }
      }
    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-10
      • 1970-01-01
      • 2016-04-07
      • 2018-03-17
      • 2020-03-04
      • 2014-03-28
      • 2016-07-14
      • 2018-06-07
      相关资源
      最近更新 更多