简体   繁体   English

如何解决:无法解决:com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0

[英]How to solve : Failed to resolve: com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0

I face this problem when trying to use mapbox in Android studio我在 Android Studio 中尝试使用 mapbox 时遇到了这个问题
Failed to resolve: com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0无法解析:com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0

what is the problem?问题是什么?

my build.gradle dependencies我的 build.gradle 依赖项


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.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0'
}

my build.gradle project我的 build.gradle 项目

buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"
    }
}

allprojects {
    repositories {
  google()
        jcenter()
        maven { url 'https://mapbox.bintray.com/mapbox' }

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

Version 9.5.0 (and 9.6.0) also exists (See release notes here: https://github.com/mapbox/mapbox-gl-native-android/blob/main/CHANGELOG.md ).版本 9.5.0(和 9.6.0)也存在(请参阅此处的发行说明: https : //github.com/mapbox/mapbox-gl-native-android/blob/main/CHANGELOG.md )。 It is just that the way to access the Maven repository has changed with Mapbox Maps SDK > v9.4.0.只是 Mapbox Maps SDK > v9.4.0 更改了访问 Maven 存储库的方式。

I would discourage you from using an outdated version like mapbox-android-sdk:8.6.7 , but go for com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0 .我不鼓励你使用过时的版本,比如mapbox-android-sdk:8.6.7 ,但去com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.0

The new way to access the mave repo is documented here: https://docs.mapbox.com/android/maps/overview/#configure-credentials此处记录了访问 mave 存储库的新方法: https ://docs.mapbox.com/android/maps/overview/#configure-credentials

You now need to create a secret access token and use it to access the maven repo, where the libraries are located.您现在需要创建一个秘密访问令牌并使用它来访问库所在的 maven 存储库。 Your module level build.gradle should contain this:您的模块级别 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'] ?: ""
      }
    }
  }
}

it's just badly explained.只是解释得不好。 you have to make a private token.你必须制作一个私人令牌。 public token does not work.公共令牌不起作用。 when you create a token there is a field with "Read:Download" just mark it and generate your token.当您创建令牌时,有一个带有“读取:下载”的字段,只需标记它并生成您的令牌。 This token should work.这个令牌应该可以工作。

Just use this safe version and it will work on your gradle.只需使用此安全版本,它就可以在您的 gradle 上使用。

implementation ('com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.0'){
        exclude group: 'group_name', module: 'module_name'
    }

Found Solution by generating private key as pointed out in previous answers, and finding an actual version on maven central, neither 9.7 nor 10 was on the maven central repository at the time of writing, using version 9.2 found here找到解决方案,通过生成之前的答案中指出的私钥,并在 maven central 上找到一个实际版本,在撰写本文时,maven 中央存储库中既没有 9.7 也没有 10,使用这里找到的 9.2 版

https://mvnrepository.com/artifact/com.mapbox.mapboxsdk/mapbox-android-sdk https://mvnrepository.com/artifact/com.mapbox.mapboxsdk/mapbox-android-sdk

Edit: Was able to use 9.7.0 mapbox by changing settings.gradle entry编辑:可以通过更改 settings.gradle 条目来使用 9.7.0 mapbox

repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

to

repositoriesMode.set(RepositoriesMode.PREFER_PROJECT) repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)

and build.gradle to add mavenCentral() and google() to allprojects repositories和 build.gradle 将 mavenCentral() 和 google() 添加到所有项目存储库

allprojects {
    repositories {
        google()
        mavenCentral()
        
        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'] ?: ""
                    }
                }
            }
        }
    }
}

The only way got my project to finally work is by looking for some pointers in the project attached here: https://github.com/mapbox/mapbox-maps-android/issues/614#issue-988592394 It uses com.mapbox.maps:android:10.0.0-rc.3 and actually works on my machine.让我的项目最终工作的唯一方法是在此处附加的项目中查找一些指针: https : //github.com/mapbox/mapbox-maps-android/issues/614#issue-988592394它使用 com.mapbox。 maps:android:10.0.0-rc.3 并且实际上在我的机器上工作。

To make my own project work, I had to change settings.gradle from this:为了使我自己的项目工作,我必须从这里更改 settings.gradle:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon
    }
}
rootProject.name = "Mapbox Map"
include ':app'

to this:对此:

rootProject.name = "Mapbox Map"
include ':app'

截屏

The default token Mapbox provides you is what I think you're using, you need to create a new private token and check this permission DOWNLOAD:READ then it should work. Mapbox 为您提供的默认令牌是我认为您正在使用的,您需要创建一个新的私有令牌并检查此权限DOWNLOAD:READ然后它应该可以工作。

I created a new token and named it first in my case, you can call it anything.我创建了一个新令牌并在我的情况下first将其命名,您可以将其命名为任何名称。

Sorry for the late reply.这么晚才回复很抱歉。 It will be helpful for others: **Remove this: maven{ url 'https://mapbox.bintray.com/mapbox' }这将对其他人有帮助:**删除这个: maven{ url 'https://mapbox.bintray.com/mapbox' }

 repositories {
    google()
    jcenter()
    mavenCentral()
    /**
    if you using => maven { url 'https://mapbox.bintray.com/mapbox' }
     so remove this line because mapbox remove repository from https://mapbox.bintray.com/mapbox
    * */
    maven { url "https://oss.sonatype.org/content/groups/public/" }
    maven { url 'https://jitpack.io' }
    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'] ?: ""
        }
    }
}

尝试一个实际存在的版本怎么样?

implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:8.6.7'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Studio 找不到库依赖项 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.0' - Android Studio can't cant find library dependency 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.7.0' 无法在一个项目中解析 com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0,但在另一个项目中可以吗? - Cannot resolve com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0 in one project, but in the other can? 找不到 com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0。 关于 MapBox 的全新安装 - Could not find com.mapbox.mapboxsdk:mapbox-android-accounts:0.7.0. on fresh installation of MapBox 我们如何在android中使用mapbox-android-sdk库? - how we can use mapbox-android-sdk library in android? onCreateView中的com.mapbox.mapboxsdk.exceptions.InvalidAccessTokenException - com.mapbox.mapboxsdk.exceptions.InvalidAccessTokenException in onCreateView Mapbox错误膨胀类com.mapbox.mapboxsdk.maps.MapView - Mapbox error inflating class com.mapbox.mapboxsdk.maps.MapView "无法解决:com.mapbox.maps:android:10.0.0" - Failed to resolve: com.mapbox.maps:android:10.0.0 W / com.mapbox.mapboxsdk.http.HTTPRequest:由于永久错误,请求失败 - W/com.mapbox.mapboxsdk.http.HTTPRequest: Request failed due to a permanent error Android 在空对象引用上的“boolean com.mapbox.mapboxsdk.maps.Style.isFullyLoaded()”上崩溃, - Android crash on 'boolean com.mapbox.mapboxsdk.maps.Style.isFullyLoaded()' on a null object reference, 膨胀类com.mapbox.mapboxsdk.views.MapView时出错 - Error inflating class com.mapbox.mapboxsdk.views.MapView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM