Android build doesn't work (Duplicate class com.google.android.gms.internal.measurement.zzbt found in modules)

Viewed 8545

It worked fine until a week ago, but this week the build didn't work and I got the following error. I tried the following, but I haven't solved it yet. Any small thing is fine, so if anyone knows any hints or solutions, please let me know.

■What I tried

  • Downgrade classpath ("com.google.gms: google-services: 4.3.3")
  • Specify the versions of com.google.android.gms: play-services-measurement-sdk-api and com.google.android.gms: play-services-measurement
  • Gradle version upgrade, downgrade

■Development environment
react:16.9.0
react-native:0.61.5
Android Gradle:4.0.0
Firebase(google-services):4.3.4


> Task :app:checkDebugDuplicateClasses FAILED

> Transform artifact play-services-measurement.aar (com.google.android.gms:play-services-measurement:17.4.4) with DexingWithClasspathTransform

> Transform artifact play-services-measurement-impl.aar (com.google.android.gms:play-services-measurement-impl:17.4.4) with DexingWithClasspathTransform
ReactNativeFirebase WARNING: NPM package '@react-native-firebase/auth' depends on '@react-native-firebase/app' v8.3.1 but found v8.4.0, this might cause build issues or runtime crashes.
501 actionable tasks: 7 executed, 494 up-to-date
D8: Type com.google.android.gms.internal.measurement.zzig is referenced as an interface from `com.google.android.gms.internal.measurement.zzby`.
D8: Interface `com.google.android.gms.measurement.internal.zzhd(classpath class)` used as super class of `com.google.android.gms.measurement.AppMeasurement$UserProperty`.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.measurement.zzbt found in modules jetified-play-services-measurement-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement:17.4.4) and jetified-play-services-measurement-sdk-api-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-sdk-api:17.5.0)
  Duplicate class com.google.android.gms.internal.measurement.zzbu found in modules jetified-play-services-measurement-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement:17.4.4) and jetified-play-services-measurement-sdk-api-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-sdk-api:17.5.0)
  Duplicate class com.google.android.gms.internal.measurement.zzfw found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)
  Duplicate class com.google.android.gms.internal.measurement.zzfy found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)
  Duplicate class com.google.android.gms.internal.measurement.zzfz found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)
  Duplicate class com.google.android.gms.internal.measurement.zzga found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)
  Duplicate class com.google.android.gms.internal.measurement.zzgb found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)
  Duplicate class com.google.android.gms.measurement.internal.zzgz found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)
  Duplicate class com.google.android.gms.measurement.internal.zzik found in modules jetified-play-services-measurement-base-17.5.0-runtime.jar (com.google.android.gms:play-services-measurement-base:17.5.0) and jetified-play-services-measurement-impl-17.4.4-runtime.jar (com.google.android.gms:play-services-measurement-impl:17.4.4)

  Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

2 Answers

I had the same issue... If you are using firebase dependencies and you are using bill of materials (bom) it might be the case you didn't update that, since Android Studio won't prompt you to do so. Right now latest bom is 26.1.1 (but check documentation), so it should look like this: implementation platform('com.google.firebase:firebase-bom:26.1.1').

The error occurs when you have dependency conflicts. For eg: You have two dependecies A and B and the required depedencies for B is already provided in A. Here the conflit occurs. More to this on [Fix Dependency resolution error][1] [1]: https://developer.android.com/studio/build/dependencies#resolution_errors

In my case, I had used Interrestial Ads and Google admob both depedencies. That was causing the error.

Solution: Press Shift button twice You should see the pupop window In the menu, select All option to the right, select "Include non project" Then search for the class that was causing the error. You should see that class name in logcat. Then remove the corresponding dependency from build.gradle (App Level)

Related