skip to Main Content

I am getting this build error while I am trying to run my application from 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 is with the latest version 20.4.0.

Can anybody help me please? Thanks in advance.

2

Answers


  1. The release notes are not giving a hint.

    I ended up using 20.3.0 for now which does not produce this error.

    Login or Signup to reply.
  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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search