'getting build error after updating ads dependencies to latest version
I am getting this build error while I am trying to run my application from the 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)
this only happens after I update ads dependencies to the latest version
From :
implementation 'com.google.android.gms:play-services-ads:20.0.0'
To :
implementation 'com.google.android.gms:play-services-ads:20.4.0'
if I change it back to 20.0.0
then it's working fine I think the problem with the latest version 20.4.0
can anybody helps me please thanks in advance.
Solution 1:[1]
The release notes are not giving a hint.
I ended up using 20.3.0 for now which does not produce this error.
Solution 2:[2]
Another Google owned library has a conflicting version of com.google.android.gms:play-services-measurement-base
installed. In my case it was Firebase Analytics.
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
After upgrading Firebase Analytics from version 18.0.0
to 20.1.2
it solved the issue.
To determine which library is conflicting in your project, output your dependency tree and find which library also installs com.google.android.gms:play-services-measurement-base
. Then upgrade that library to the latest version.
See also
- Duplicate class com.google.android.gms.internal.measurement.zzdu found in modules classes.jar com.google.android.gms:play-services-measurement-impl:
- com.google.android.gms:play-services-measurement-base is being requested by various other libraries
- Fix dependency resolution errors
- View module dependencies
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Uwe Post |
Solution 2 | Ryan Payne |