在将广告依赖项更新到最新版本后获得构建错误



当我试图从Android Studio.运行我的应用程序时,我得到了这个构建错误

Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.measurement.zzbs found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-sdk-api-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
Duplicate class com.google.android.gms.internal.measurement.zzl found in modules jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1) and jetified-play-services-measurement-sdk-api-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzfh found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)
Duplicate class com.google.android.gms.measurement.internal.zzgl found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzgm found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzgn found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzgo found in modules jetified-play-services-measurement-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement:18.0.1) and jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3)
Duplicate class com.google.android.gms.measurement.internal.zzgp found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)
Duplicate class com.google.android.gms.measurement.internal.zzgq found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)
Duplicate class com.google.android.gms.measurement.internal.zzhs found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)
Duplicate class com.google.android.gms.measurement.internal.zzhx found in modules jetified-play-services-measurement-base-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-base:18.0.3) and jetified-play-services-measurement-impl-18.0.1-runtime.jar (com.google.android.gms:play-services-measurement-impl:18.0.1)

这只发生在我更新广告到最新版本的依赖关系。

:

implementation 'com.google.android.gms:play-services-ads:20.0.0'

:

implementation 'com.google.android.gms:play-services-ads:20.4.0'

如果我把它改回20.0.0,那么它工作得很好。我想问题出在最新版本的20.4.0上。

有谁能帮帮我吗?提前谢谢。

发布说明没有给出任何提示。

我现在使用20.3.0,它不会产生这个错误。

另一个Google拥有的库安装了一个冲突的com.google.android.gms:play-services-measurement-base版本。在我的例子中,它是Firebase Analytics。

重火力点分析

+--- com.google.firebase:firebase-analytics:18.0.0
|    +--- com.google.android.gms:play-services-measurement:18.0.0

Play Services Ads

+--- com.google.android.gms:play-services-ads:20.6.0
|    +--- com.google.android.gms:play-services-ads-lite:20.6.0
|    |    +--- com.google.android.gms:play-services-measurement-sdk-api:18.0.3
|    |    |    --- com.google.android.gms:play-services-measurement-base:18.0.3

将Firebase Analytics从18.0.0版本升级到20.1.2后,问题就解决了。

要确定在项目中哪个库是冲突的,输出依赖关系树并找到哪个库也安装了com.google.android.gms:play-services-measurement-base。然后将库升级到最新版本。

参见

  • 在modules中找到的复制类com.google.android.gms.internal.measurement.zzdu:
  • com.google.android。gms:play-services-measurement-base正在被其他各种库请求
  • 修复依赖解析错误
  • 查看模块依赖

相关内容

  • 没有找到相关文章

最新更新