【问题标题】:Migrating from deprecated jcenter - issue with Google Places library从已弃用的 jcenter 迁移 - Google Places 库的问题
【发布时间】:2021-10-15 20:43:51
【问题描述】:

我正在尝试从我的项目中删除 jcenter(),因为它已被弃用。但我使用的是当前最新版本的com.google.android.libraries.places:places:2.4.0 依赖项,官方docs 中对此进行了概述。有趣的是,当我尝试构建项目时它失败了,因为它找不到依赖项com.android.volley:volley:1.1.1。我没有直接在我的项目中使用这个依赖,但我发现它是places库中的传递依赖。

当我执行gradlew app:dependencies时,我可以看到这样的情况:

+--- com.google.android.libraries.places:places:2.4.0
|    +--- androidx.appcompat:appcompat:1.0.0 -> 1.3.1 (*)
|    +--- androidx.cardview:cardview:1.0.0 (*)
|    +--- androidx.fragment:fragment:1.1.0 -> 1.3.6 (*)
|    +--- androidx.lifecycle:lifecycle-extensions:2.1.0 -> 2.2.0 (*)
|    +--- androidx.recyclerview:recyclerview:1.0.0 -> 1.2.1 (*)
|    +--- com.android.volley:volley:1.1.1 FAILED
|    +--- com.google.android.datatransport:transport-api:2.2.0 -> 3.0.0 (*)
|    +--- com.google.android.datatransport:transport-backend-cct:2.3.0 -> 3.0.0 (*)
|    +--- com.google.android.datatransport:transport-runtime:2.2.3 -> 3.0.0 (*)
|    +--- com.google.android.gms:play-services-base:17.2.1 -> 17.5.0 (*)
|    +--- com.google.android.gms:play-services-basement:17.0.0 -> 17.5.0 (*)
|    +--- com.google.android.gms:play-services-location:17.0.0 -> 18.0.0 (*)
|    +--- com.google.android.gms:play-services-maps:17.0.0
|    |    +--- androidx.fragment:fragment:1.0.0 -> 1.3.6 (*)
|    |    +--- com.google.android.gms:play-services-base:17.0.0 -> 17.5.0 (*)
|    |    \--- com.google.android.gms:play-services-basement:17.0.0 -> 17.5.0 (*)
|    +--- com.google.android.gms:play-services-tasks:17.0.0 -> 17.2.0 (*)
|    +--- com.google.auto.value:auto-value-annotations:1.6.2
|    \--- com.google.code.gson:gson:2.8.5 -> 2.8.7

所以,com.google.android.libraries.places:places:2.4.0 使用过时的库 com.android.volley:volley:1.1.1。有趣的是,com.android.volley 托管在 mavenCentral 上,仅从 1.2.0 版本开始。而1.1.1 版本仅在Bintray 中可用:https://mvnrepository.com/artifact/com.android.volley/volley/1.1.1

我的顶级配置:

buildscript {
    ext.kotlin_version = '1.5.21'

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0'
        classpath 'com.google.gms:google-services:4.3.10'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

那么,即使 Google 也没有,我该如何从 jcenter 迁移?还是我错过了什么?

【问题讨论】:

    标签: android maven google-places-api jcenter


    【解决方案1】:

    现在您可以单独手动包含 Volley 依赖项,并从 Places 依赖项中排除 1.1.1 版本。

    implementation('com.google.android.libraries.places:places:2.4.0') {
        exclude group: 'com.android.volley'
    }
    implementation 'com.android.volley:volley:1.2.0'
    

    正如您指出的那样,Volley 现在位于 Maven Central 上,因此您还需要包含 mavenCentral() 存储库。

    【讨论】:

    • 我认为没有必要排除v1.1.1,因为当您手动包含它时,它会被v1.2.0 覆盖。
    猜你喜欢
    • 2021-05-12
    • 1970-01-01
    • 1970-01-01
    • 2015-02-18
    • 1970-01-01
    • 2016-01-17
    • 2020-02-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多