Duplicate Class while using firebase and google-cloud-texttospeech - android

I am having an android project using firestore, firebase-auth and FCM . Now when I am adding google-cloud-texttospeech to my project I am getting 'Duplicate class' error
Here is my dependencies
//Firebase
implementation "com.google.firebase:firebase-core:17.0.0"
implementation "com.google.firebase:firebase-firestore:20.1.0"
/*implementation "com.crashlytics.sdk.android:crashlytics:$rootProject.crashlytics"*/
implementation "com.google.firebase:firebase-messaging:19.0.1"
implementation "com.google.firebase:firebase-auth:18.0.0"
// Ad-mob
implementation "com.google.android.gms:play-services-ads:18.0.0"
implementation ("com.google.cloud:google-cloud-texttospeech:0.97.0-beta")
This is the error I am getting while building the project.
Duplicate class com.google.api.Advice found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Advice$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Advice$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AdviceOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AnnotationsProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProvider found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProvider$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProvider$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthProviderOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirement found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirement$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirement$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthRequirementOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Authentication found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Authentication$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.Authentication$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthenticationOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Duplicate class com.google.api.AuthenticationRule found in modules classes.jar (com.google.firebase:protolite-well-known-types:17.0.0) and proto-google-common-protos-1.16.0.jar (com.google.api.grpc:proto-google-common-protos:1.16.0)
Now I understand the firebase and google-cloud-texttospeech is using same classes inside there dependencies.
So I tried to exclude those by
implementation ("com.google.cloud:google-cloud-texttospeech:0.97.0-beta"){
exclude group: 'com.google.api.grpc', module: 'proto-google-common-protos'
exclude group: 'com.google.protobuf', module: 'protobuf-lite'
exclude group: 'com.google.protobuf', module: 'protobuf-java'
}
Then the app is building but crashes while speech synthesising
2019-07-03 20:04:15.861 24851-24851/package.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: package.dev, PID: 24851
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/protobuf/GeneratedMessageV3;
at com.google.cloud.texttospeech.v1.TextToSpeechClient.create(TextToSpeechClient.java:101)
at package_name.tts.TextSpeachAPI.<init>(TextSpeachAPI.kt:8)
at package_name.ui.home.sofar.WordDetailsVM.speak(WordDetailsVM.kt:318)
at package_name.ui.home.sofar.WordDetailsFragment$listeners$11.onClick(WordDetailsFragment.kt:264)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.protobuf.GeneratedMessageV3" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/package_name.dev-apgPZPeLvH3LUXKWw2gBbg==/base.apk"],nativeLibraryDirectories=[/data/app/package_name.dev-apgPZPeLvH3LUXKWw2gBbg==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.cloud.texttospeech.v1.TextToSpeechClient.create(TextToSpeechClient.java:101) 
at package_name.tts.TextSpeachAPI.<init>(TextSpeachAPI.kt:8) 
at package_name.ui.home.sofar.WordDetailsVM.speak(WordDetailsVM.kt:318) 
at package_name.ui.home.sofar.WordDetailsFragment$listeners$11.onClick(WordDetailsFragment.kt:264) 
at android.view.View.performClick(View.java:6597) 
at android.view.View.performClickInternal(View.java:6574) 
at android.view.View.access$3100(View.java:778) 
at android.view.View$PerformClick.run(View.java:25885) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:6669) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

I experienced such a problem when using "google cloud speech".
In the use of "firestore" and "google cloud speech", I showed duplicate classes in "protobuf-java", "protobuf-lite", "proto-google-common-protos" and "protolite-well-known-types" I solved the problem by unzipping the jar files and creating a new jar file with no duplicate classes. Please refer to the github project I posted below.
https://github.com/ivso0001/GoogleCloudSpeechAndFirebaseIntegration

This worked for me:
android{
...
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/INDEX.LIST'
}
}
dependencies{
...
implementation ('com.google.cloud:google-cloud-speech:0.41.0-alpha'){
exclude module: 'protobuf-javalite'
exclude module: 'protobuf-java'
exclude module: 'proto-google-common-protos'
}
}
Ref:
https://github.com/GoogleCloudPlatform/android-docs-samples/blob/master/speech/SpeechRecognitionClient/app/build.gradle
https://stackoverflow.com/a/64226363/8459761

Related

Duplicate class com.google.android.gms.internal.measurement.zzdu found in modules classes.jar com.google.android.gms:play-services-measurement-impl:

This question may have been asked with some other context and dependencies.
But I am still not able to figure out this even spending a whole day.
So below I'm pasting the complete Error log along with my Project level Gradle file and App level Gradle file.
Error log while trying to run the app:
Duplicate class com.google.android.gms.internal.measurement.zzdu found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzdv found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzdw found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzdx found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzdy found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzdz found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzea found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzeb found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzec found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzed found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzee found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzef found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzeg found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzeh found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzei found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzej found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzek found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzel found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzem found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzen found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzeo found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzep found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzeq found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzer found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzes found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzet found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzeu found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzev found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzew found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzex found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzey found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzez found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzfa found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzfb found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzfc found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzfd found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgb found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgc found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgd found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzge found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgf found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgg found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgh found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgi found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgj found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgk found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgl found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgm found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgn found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgo found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgp found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgq found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgr found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgs found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgt found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgu found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgv found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgw found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgx found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgy found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzgz found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzha found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhb found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhc found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhd found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhe found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhf found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhg found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhh found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhi found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhj found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhk found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhl found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhm found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhn found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzho found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhp found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhq found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhr found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhs found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzht found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhu found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhv found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhw found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhx found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhy found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzhz found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzia found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzib found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzic found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzid found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzie found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzif found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Duplicate class com.google.android.gms.internal.measurement.zzig found in modules classes.jar (com.google.android.gms:play-services-measurement-impl:17.0.0) and classes.jar (com.google.firebase:firebase-analytics-impl:15.0.2)
Go to the documentation to learn how to Fix dependency resolution errors.
My Project Gradle File:
`// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'http://maven.google.com' }
maven {
url 'https://maven.fabric.io/public'
}
maven{
url 'http://dl.bintray.com/amulyakhare/maven'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.2'
classpath 'io.fabric.tools:gradle:1.25.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
`
App level build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.package.app"
minSdkVersion 17
targetSdkVersion 28
versionCode 4
versionName "0.4"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//resConfigs "en"
manifestPlaceholders = [
onesignal_app_id: 'API_KEY',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
//minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable true
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/res/assets/'] } }
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.browser:browser:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation('com.mikepenz:materialdrawer:6.0.6#aar') {
transitive = true
}
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'com.mikepenz:fastadapter:3.2.4#aar'
implementation 'com.mikepenz:fastadapter-commons:3.2.4#aar'
implementation 'com.mikepenz:fastadapter-extensions:3.2.4#aar'
implementation 'com.mikepenz:fastadapter-extensions-expandable:3.2.4#aar'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
implementation 'com.firebaseui:firebase-ui-auth:6.0.2'
implementation 'com.google.firebase:firebase-auth:19.1.0'
//implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation("com.google.android.gms:play-services-analytics:17.0.0") {
exclude group: 'com.google.android.gms', module: 'play-services-measurement'
exclude group: 'com.google.android.gms', module: 'firebase-analytics-impl:15.0.2'
}
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.facebook.android:audience-network-sdk:4.99.1'
//implementation 'com.google.android.gms:play-services-ads:18.2.0'
implementation("com.google.android.gms:play-services-ads:18.2.0") {
exclude group: 'com.google.android.gms' , module: 'play-services-measurement'
exclude group: 'com.google.android.gms', module: 'firebase-analytics-impl:15.0.2'
}
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.synnapps:carouselview:0.1.5'
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.stephentuso:welcome:1.4.1'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:8.0.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'androidx.room:room-runtime:2.1.0'
annotationProcessor 'androidx.room:room-compiler:2.1.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
}
apply plugin: 'com.google.gms.google-services'
googleServices { disableVersionCheck = true }
In ReactNative I have the next error:
Duplicate class com.google.android.gms.internal.measurement.zzbp found in moduules play-services-measurement-17.4.1-runtime.jar (com.google.android.gms:play-seervices-measurement:17.4.1) and play-services-measurement-sdk-api-18.0.3-runtime.jar (com.google.android.gms:play-services-measurement-sdk-api:18.0.3)
It solved changing the next line on the build.gradle of android app level:
implementation 'com.google.firebase:firebase-analytics:17.4.1'
to
implementation 'com.google.firebase:firebase-analytics:18.0.3'
This was my problem also..i looked for the last dependency added, and that was
implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
What I only did, is to reduce to number lower than that, because need for it. And it worked.
implementation 'com.google.firebase:firebase-ml-vision:24.0.0'
Regards Nenad
What worked for me was deleting the dependency "'com.google.gms:google-services:4.3.2'" Since I am using Flutter, it seems that the Flutter framework already addss this. So at runtime the project finds 2 dependencies. Try it.
Solved downgrading
implementation 'com.google.android.gms:play-services-ads:21.2.0'
To
implementation 'com.google.android.gms:play-services-ads:20.0.0'
Using react-native-text-detector caused this for me. Removing this essentially fixed this error. Its a bit extreme but its better than wasting hours of valuable time on this.
Just add this api in your dependencies in gradle
This will solve your problem
api 'com.google.firebase:firebase-core:21.1.1'
I hope this helps you

How to prevent the duplicating classes error in Android

I am using Tesseract and Scanbot Android Document Scanner SDK. Both contain the same class for OCR reading. Since I am using Tesseract I no need to go for the Scanbot PII package which is offering PI packages + OCR. But unfortunately, their PI also contains the Tesseract modules. I need to exclude those classes from scanbot and I tried similar question's answers but it doesn't help.
Gradle:
implementation 'com.rmtheis:tess-two:6.0.0'
implementation 'io.scanbot:sdk-package-ui:$scanbotSdkVersion'
implementation ("io.scanbot:sdk-package-1:$scanbotSdkVersion"){
exclude group: "com.googlecode.leptonica.android"
}
It gives the following error:
Duplicate class com.googlecode.leptonica.android.AdaptiveMap found in
modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Binarize found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Box found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Boxa found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Clip found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Constants found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Convert found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Edge found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Enhance found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.GrayQuant found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.JpegIO found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.MorphApp found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Pix found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Pixa found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Pixa$1 found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Pixa$PixIterator found in
modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)
Duplicate class com.googlecode.leptonica.android.ReadFile found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Rotate found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Scale found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Scale$1 found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Scale$ScaleType found in
modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)
Duplicate class com.googlecode.leptonica.android.Skew found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.leptonica.android.WriteFile found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class com.googlecode.tesseract.android.PageIterator found in
modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)
Duplicate class com.googlecode.tesseract.android.ResultIterator found in
modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)
Duplicate class com.googlecode.tesseract.android.TessBaseAPI found in modules
classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar (io.scanbot:sdk-
core:1.54.0)
Duplicate class
com.googlecode.tesseract.android.TessBaseAPI$PageIteratorLevel found in
modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)
Duplicate class com.googlecode.tesseract.android.TessBaseAPI$PageSegMode
found
in modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)
Duplicate class com.googlecode.tesseract.android.TessBaseAPI$ProgressNotifier
found in modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)
Duplicate class com.googlecode.tesseract.android.TessBaseAPI$ProgressValues
found in modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)
Duplicate class com.googlecode.tesseract.android.TessPdfRenderer found in
modules classes.jar (com.rmtheis:tess-two:6.0.0) and classes.jar
(io.scanbot:sdk-core:1.54.0)

Android studio Gradle "exclude" is not working as intended

Gradle exclude doesn't work as expected.
Currently, I'm using Firebase Firestore in android application, Firestore uses "protobuf-lite" internally which conflict with another library that uses "protobuf-java" which produces duplicate class gradle error and build fail.
Duplicate class com.google.protobuf.AbstractMessageLite found in modules protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractMessageLite$Builder found in modules protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractMessageLite$Builder$LimitedInputStream found in modules protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractParser found in modules protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.AbstractProtobufList found in modules protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
Duplicate class com.google.protobuf.Any found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0)
Duplicate class com.google.protobuf.Any$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0)
Duplicate class com.google.protobuf.Any$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0)
Duplicate class com.google.protobuf.AnyProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0)
Duplicate class com.google.protobuf.Api found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and protobuf-java-3.0.0.jar (com.google.protobuf:protobuf-java:3.0.0)
I added a rule to Firestore implementation to exclude these modules that conflict with other libraries
implementation('com.google.firebase:firebase-firestore:20.1.0', {
exclude group: 'com.google.firebase', module:'protolite-well-known-types'
exclude group: 'com.google.firebase', module:'protobuf-lite'
exclude group: 'com.google.protobuf', module:'protobuf-lite'
})
Now, the project built successfully and the app runs but the app crashes when I make any Firestore operation which means that they are excluded from Firestore library itself not only from the app module.
java.lang.RuntimeException: Internal error in Firestore (20.1.0).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$5(com.google.firebase:firebase-firestore##20.1.0:379)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run(com.google.firebase:firebase-firestore##20.1.0)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6274)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.VerifyError: Verifier rejected class com.google.firestore.v1.WriteResponse: void com.google.firestore.v1.WriteResponse.mergeCommitTime(com.google.protobuf.Timestamp) failed to verify: void com.google.firestore.v1.WriteResponse.mergeCommitTime(com.google.protobuf.Timestamp): [0x10] register v3 has type Precise Reference: com.google.protobuf.Timestamp but expected Reference: com.google.protobuf.GeneratedMessageLiteVerifier rejected class com.google.firestore.v1.WriteResponse: java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object) failed to verify: java.lang.Object com.google.firestore.v1.WriteResponse.dynamicMethod(com.google.protobuf.GeneratedMessageLite$MethodToInvoke, java.lang.Object, java.lang.Object): [0x73] register v5 has type Precise Reference: com.google.protobuf.Timestamp but expected Reference: com.google.protobuf.GeneratedMessageLite (declaration of 'com.google.firestore.v1.WriteResponse' appears in /data/app/com.demo.myapplication-2/base.apk)
at com.google.firestore.v1.WriteResponse.getDefaultInstance(com.google.firebase:firebase-firestore##20.1.0:1012)
at com.google.firestore.v1.FirestoreGrpc.getWriteMethod(com.google.firebase:firebase-firestore##20.1.0:379)
at com.google.firebase.firestore.remote.WriteStream.<init>(com.google.firebase:firebase-firestore##20.1.0:74)
at com.google.firebase.firestore.remote.Datastore.createWriteStream(com.google.firebase:firebase-firestore##20.1.0:104)
at com.google.firebase.firestore.remote.RemoteStore.<init>(com.google.firebase:firebase-firestore##20.1.0:186)
at com.google.firebase.firestore.core.FirestoreClient.initialize(com.google.firebase:firebase-firestore##20.1.0:263)
at com.google.firebase.firestore.core.FirestoreClient.lambda$new$2(com.google.firebase:firebase-firestore##20.1.0:117)
at com.google.firebase.firestore.core.FirestoreClient$$Lambda$2.run(com.google.firebase:firebase-firestore##20.1.0)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$4(com.google.firebase:firebase-firestore##20.1.0:311)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$4.call(com.google.firebase:firebase-firestore##20.1.0)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$3(com.google.firebase:firebase-firestore##20.1.0:287)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(com.google.firebase:firebase-firestore##20.1.0)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run(com.google.firebase:firebase-firestore##20.1.0:205)
at java.lang.Thread.run(Thread.java:761)
The question is:
Doesn't exclude means that don't import these modules from Firestore library to the app module but don't remove them from Firestore?
If not, then how can I make them only available for internal Firestore usage only and hidden from the app module to avoid any conflict and duplicate class errors.
======= Update ==========
I fixed the problem
As we can't change the Firestore internal code that depends on protolite version then the only way was changing the other module that depends on proto-java to use protolite to fix this duplicate error, and to do that
I had to use protobuf lite compiler to generate java classes from the proto files which will generate classes that depend on the protolite library instead of proto-jave and now I can use the proto-lite library for both Firestore and the other Module and duplicate classes error gone.

Duplicate classes when building app with firebase-firestore and google-cloud-language - android

I'm getting duplicate class errors when I try to build android app that use firebase-firestore and google-cloud-language.
Duplicate class com.google.api.Advice found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
Duplicate class com.google.api.Advice$1 found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
Duplicate class com.google.api.Advice$Builder found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
Duplicate class com.google.api.AdviceOrBuilder found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
...
Duplicate class com.google.type.TimeOfDayProto found in modules classes.jar (com.google.firebase:protolite-well-known-types:16.0.1) and proto-google-common-protos-1.15.0.jar (com.google.api.grpc:proto-google-common-protos:1.15.0)
My build.gradle looks like follow:
...
dependencies {
...
implementation 'com.google.firebase:firebase-ml-vision:20.0.0'
implementation 'com.google.firebase:firebase-firestore:19.0.0'
implementation 'io.grpc:grpc-okhttp:1.19.0'
implementation'com.google.cloud:google-cloud-language:1.76.0'
}
How can I solve the issuse ?

Manifest merger error with com.google.android.material:material

I am getting following error :
Duplicate class android.support.v4.app.INotificationSideChannel found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
Duplicate class android.support.v4.os.IResultReceiver$Stub$Proxy found in modules classes.jar (androidx.core:core:1.0.0) and classes.jar (com.android.support:support-compat:26.1.0)
.......
andin my gradle file there is following dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
}
I do not know what is the problem I tried multiple solution including this but did not get rid of this. Please help
It seems like a conflict between androidX and support libs.
If you are not supporting yet androidX you need to replace
implementation 'com.google.android.material:material:1.0.0' by implementation 'com.android.support:design:28.0.0'.
If you still want to use the material version, make sure your gradle.properties file has androidX and Jetifier enabled.
android.useAndroidX=true
android.enableJetifier=true
Make sure you follow the necessary setup to use material. Check it out here.

Categories

Resources