When I am adding com.google.firebase:firebase-config:19.1.0
to use firebase remote config having this issue.
java.lang.RuntimeException: Duplicate class com.google.protobuf.AbstractMessageLite found in modules protobuf-java-2.5.0.jar (com.google.protobuf:protobuf-java:2.5.0) and protobuf-lite-3.0.1.jar (com.google.protobuf:protobuf-lite:3.0.1)
I have updated both firebase-analytics
and google-play-services
to latest version. But still the problem exist.
But when I changed remote config to older version 18.0.0 or less
then its working fine. But I want to use the latest version.
My dependencies:
firebase_analytics : "com.google.firebase:firebase-analytics:17.2.2",
fcm : "com.google.firebase:firebase-messaging:20.1.0",
performance : "com.google.firebase:firebase-perf:19.0.0",
config : "com.google.firebase:firebase-config:19.0.0",
Also tried to exclude below doesn't work:
exclude group: 'com.google.protobuf', module: 'protobuf-lite'
exclude group: 'com.google.protobuf', module: 'protobuf-java'
Finally, I fixed this issue. First lets understand the issue:
protobuf-java
and protobuf-lite
are incompatible packages. They both include classes in the com.google.protobuf
package. protobuf-java
is typically used in packages intended for desktop and server-side use (i.e. regular Java), while protobuf-lite
is frequently used in packages that target Android.
Firebase packages depend upon protobuf-lite
. Something else in your project must depend on protobuf-java
. You can see a tree view of your dependencies by following these instructions: https://stackoverflow.com/a/35235229.
The exclusion is required to resolve the incompatibility, though really you should see if there's an android-specific variant of whatever package you're using that's introducing protobuf-java
.
To exclude the duplicate classes that's causing the problem, add the following code into your build.gradle (app module) file:
android {
...
configurations {
implementation.exclude module:'protobuf-lite'
}
}
try this, add the code in app's build
configurations {
implementation.exclude module:'protobuf-java'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With