首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Android:在模块中发现的重复类-游戏.服务.度量和训练.服务.测量.impl

Android:在模块中发现的重复类-游戏.服务.度量和训练.服务.测量.impl
EN

Stack Overflow用户
提问于 2022-06-02 17:32:48
回答 2查看 6.6K关注 0票数 26

我正在尝试更新我的一个Android项目的依赖项,并得到了这个奇怪的错误。

AdMob的罪魁祸首是这一行(我以前使用过20.6.0):

代码语言:javascript
运行
复制
implementation "com.google.android.gms:play-services-ads:21.0.0"

我犯了一大堆错误:

在模块中找到重复类com.google.android.gms.internal.measurement.zzhx,在模块中找到jetified-play-services-measurement-base-20.1.2-runtime (com.google.android.gms:play-services-measurement-base:20.1.2)和jetified-play-services-measurement-impl-20.1.1-runtime (com.google.android.gms:play-services-measurement-impl:20.1.1)重复类com.google.android.gms.internal.measurement.zzna-服务-测量-基本-20.1.2-运行时(com.google.android.gms:play-services-measurement-base:20.1.2)和jetified-play-services-measurement-impl-20.1.1-runtime (com.google.android.gms:play-services-measurement-impl:20.1.1)重复类com.google.android.gms.internal.measurement.zznb在模块jetified-play-services-measurement-base-20.1.2-runtime (com.google.android)中找到。gms:play-services.度量-基本值:20.1.2)和jetified-play-services-measurement-impl-20.1.1-runtime (com.google.android.gms:play-services-measurement-impl:20.1.1)重复类com.google.android.gms.internal.measurement.zznc在模块jetified-play-services-measurement-base-20.1.2-runtime (com.google.android.gms:play-services-measurement-base:20.1.2)和jetified中找到服务-测量-IMPL-20.1.1-运行时(com.google.android.gms:play-services-measurement-impl:20.1.1)。

下面是我在项目的build.gradle (:app)中使用的所有依赖项

代码语言:javascript
运行
复制
dependencies {
    implementation "androidx.recyclerview:recyclerview:1.2.1"
    implementation 'androidx.core:core-ktx:1.8.0'
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    // Firebase & Crashlytics
    implementation platform('com.google.firebase:firebase-bom:29.2.1')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
    //Navigation
    implementation "androidx.navigation:navigation-fragment-ktx:2.4.2"
    implementation "androidx.navigation:navigation-ui-ktx:2.4.2"
    // AdMob
    implementation "com.google.android.gms:play-services-ads:21.0.0"
    // Style
    implementation 'com.intuit.sdp:sdp-android:1.0.5'
    // Play Core
    implementation 'com.google.android.play:core:1.10.3'
    implementation 'com.google.android.play:core-ktx:1.8.1'
    // Billing
    implementation "com.android.billingclient:billing-ktx:5.0.0"
}

build.gradle (My App)中的依赖项

代码语言:javascript
运行
复制
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.1.3"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.2"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
        classpath "com.google.gms:google-services:4.3.10"
        classpath "com.google.firebase:firebase-crashlytics-gradle:2.8.1"
    }
}

是什么导致了这个错误?如果将play-services-ads恢复为20.6.0,则不会出现任何错误。

谢谢你的帮助

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-06-03 13:26:30

还需要将implementation platform('com.google.firebase:firebase-bom:29.2.1'),更新为

代码语言:javascript
运行
复制
 implementation platform('com.google.firebase:firebase-bom:30.1.0')
票数 69
EN

Stack Overflow用户

发布于 2022-10-26 03:11:28

正如错误消息中所述,需要解析/删除一些重复的类(很可能还有不兼容的版本设置)。对于我的情况,我需要升级我的。我就是这样追踪问题的:

我跑了

代码语言:javascript
运行
复制
./gradlew -q app:dependencies

通过搜索play-services-measurement来发现以下片段

代码语言:javascript
运行
复制
|    |    |    +--- com.google.android.gms:play-services-ads:21.2.0
|    |    |    |    +--- androidx.browser:browser:1.4.0
|    |    |    |    |    +--- androidx.collection:collection:1.1.0 -> 1.2.0 (*)
|    |    |    |    |    +--- androidx.concurrent:concurrent-futures:1.0.0 (*)
|    |    |    |    |    +--- androidx.interpolator:interpolator:1.0.0 (*)
|    |    |    |    |    +--- androidx.core:core:1.1.0 -> 1.8.0 (*)
|    |    |    |    |    +--- androidx.annotation:annotation:1.1.0 -> 1.3.0
|    |    |    |    |    \--- com.google.guava:listenablefuture:1.0 -> 9999.0-empty-to-avoid-conflict-with-guava
|    |    |    |    +--- androidx.collection:collection:1.0.0 -> 1.2.0 (*)
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.8.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-ads-base:21.2.0
|    |    |    |    |    \--- com.google.android.gms:play-services-basement:18.0.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-ads-identifier:18.0.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-ads-lite:21.2.0
|    |    |    |    |    +--- androidx.work:work-runtime:2.7.0 -> 2.7.1
|    |    |    |    |    |    +--- androidx.annotation:annotation-experimental:1.0.0 -> 1.1.0
|    |    |    |    |    |    +--- com.google.guava:listenablefuture:1.0 -> 9999.0-empty-to-avoid-conflict-with-guava
|    |    |    |    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.1.0 -> 2.5.1 (*)
|    |    |    |    |    |    +--- androidx.startup:startup-runtime:1.0.0 -> 1.1.1 (*)
|    |    |    |    |    |    +--- androidx.core:core:1.6.0 -> 1.8.0 (*)
|    |    |    |    |    |    +--- androidx.room:room-runtime:2.2.5 -> 2.4.2 (*)
|    |    |    |    |    |    +--- androidx.sqlite:sqlite:2.1.0 -> 2.2.0 (*)
|    |    |    |    |    |    +--- androidx.sqlite:sqlite-framework:2.1.0 -> 2.2.0 (*)
|    |    |    |    |    |    +--- androidx.core:core:1.1.0 -> 1.8.0 (*)
|    |    |    |    |    |    \--- androidx.lifecycle:lifecycle-service:2.1.0 -> 2.4.0 (*)
|    |    |    |    |    +--- com.google.android.gms:play-services-ads-base:21.2.0 (*)
|    |    |    |    |    +--- com.google.android.gms:play-services-basement:18.0.0 (*)
|    |    |    |    |    +--- com.google.android.gms:play-services-measurement-sdk-api:20.1.2 (*)
代码语言:javascript
运行
复制
|    +--- com.google.firebase:firebase-analytics:18.0.3
|    |    +--- com.google.android.gms:play-services-measurement:18.0.3
|    |    |    +--- androidx.collection:collection:1.0.0 -> 1.2.0 (*)
|    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-ads-identifier:17.0.0 -> 18.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 -> 18.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-base:18.0.3 -> 20.1.2 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-impl:18.0.3
|    |    |    |    +--- androidx.collection:collection:1.0.0 -> 1.2.0 (*)
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.8.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-ads-identifier:17.0.0 -> 18.0.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 -> 18.0.0 (*)
|    |    |    |    +--- com.google.android.gms:play-services-measurement-base:18.0.3 -> 20.1.2 (*)
|    |    |    |    \--- com.google.android.gms:play-services-stats:17.0.0
|    |    |    |         +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    |         \--- com.google.android.gms:play-services-basement:17.0.0 -> 18.0.0 (*)
|    |    |    \--- com.google.android.gms:play-services-stats:17.0.0 (*)
|    |    +--- com.google.android.gms:play-services-measurement-api:18.0.3
|    |    |    +--- com.google.android.gms:play-services-ads-identifier:17.0.0 -> 18.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-basement:17.0.0 -> 18.0.0 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-base:18.0.3 -> 20.1.2 (*)
|    |    |    +--- com.google.android.gms:play-services-measurement-sdk-api:18.0.3 -> 20.1.2 (*)
|    |    |    +--- com.google.android.gms:play-services-tasks:17.0.0 -> 18.0.1 (*)
|    |    |    +--- com.google.firebase:firebase-common:19.3.0 -> 20.0.0 (*)
|    |    |    +--- com.google.firebase:firebase-components:16.0.0 -> 17.0.0 (*)
|    |    |    +--- com.google.firebase:firebase-installations:16.3.2 -> 17.0.0 (*)
|    |    |    +--- com.google.firebase:firebase-installations-interop:16.0.0 -> 17.0.0 (*)
|    |    |    \--- com.google.firebase:firebase-measurement-connector:18.0.0 (*)
|    |    \--- com.google.android.gms:play-services-measurement-sdk:18.0.3

所以很明显,问题就在我的项目的这两个直接依赖项中,com.google.android.gms:play-services-ads:21.2.0com.google.firebase:firebase-analytics:18.0.3都指定了不同版本的play-services-measurement

如果我们再看一步play-services-measurement:18.0.3的pom文件

代码语言:javascript
运行
复制
    <dependency>
      <groupId>com.google.android.gms</groupId>
      <artifactId>play-services-measurement-base</artifactId>
      <version>[18.0.3]</version>
      <scope>compile</scope>
      <type>aar</type>
    </dependency>
    <dependency>
      <groupId>com.google.android.gms</groupId>
      <artifactId>play-services-measurement-impl</artifactId>
      <version>[18.0.3]</version>
      <scope>compile</scope>
      <type>aar</type>
    </dependency>

它要求严格的18.0.3的baseimpl,这使得Gradle无法自己解决问题。

我选择将火基分析升级到20.1.2,问题就解决了。

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

https://stackoverflow.com/questions/72480174

复制
相关文章

相似问题

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