Reputation: 103
Just started this error on Android build. Please help. "Duplicate class com.google.android.gms.internal.firebase_messaging.zza found in modules jetified-firebase-iid-19.0.0-runtime.jar (com.google.firebase:firebase-iid:19.0.0) and jetified-firebase-messaging-22.0.0-runtime.jar (com.google.firebase:firebase-messaging:22.0.0)"
Upvotes: 10
Views: 11826
Reputation: 7109
BOM 31.x does have currently this problem.
See issue here:
https://github.com/firebase/firebase-android-sdk/issues/4206
Resolved via issue here but not yet official released:
https://github.com/firebase/firebase-android-sdk/pull/4225
Comment:
it was not resolved yet, 31.0.1 only contained a fix to crashlytics crash bug. That's why this issue is still open. The team here will make a fix close the issue, then do a release likely with release notes indicating it is fixed, when it is fixed https://firebase.google.com/support/release-notes/android - here
A current workaround is to add the iid version explicitly until a new BOM version is released:
implementation platform('com.google.firebase:firebase-bom:31.0.0')
implementation 'com.google.firebase:firebase-functions'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-iid:21.1.0'
Upvotes: 4
Reputation: 69
Using react-native-push-notification ^3.1.9, I've got the same error.
To fix it :
in project/build.gradle:
buildscript {
ext {
googlePlayServicesVersion = "17.0.0"
firebaseMessagingVersion = "20.1.0"
firebaseVersion = "20.1.0"
// other settings
}
// other settings
}
in project/app/build.gradle:
dependencies {
implementation "com.google.firebase:firebase-messaging:20.1.0"
// other implementations
}
The reason : react-native-push-notification
package specify dependency to firebase-messaging:+
: which ask to get the last version.
So, gradle upload the latest com.google.firebase:firebase-messaging:22.x.x
which declare already existing classes in firebase-iid.
Upvotes: 2
Reputation: 4759
If you don't want to use firebase-bom
because you don't trust firebase to keep all the proper versions in check then you can remove the duplicate.
./gradlew app:dependencies
(or replace app
with your module)iid:19.0.0
(or whatever version is giving you issues)You should see something like \--- com.google.firebase:firebase-iid:19.0.0
+
eg (+--- com.google.firebase:firebase-ml-vision
)iid
api("com.google.firebase:firebase-ml-vision:$version") {
exclude group: 'com.google.firebase', module: 'firebase-iid'
}
Upvotes: 1
Reputation: 259
In build.gradle:
implementation "com.google.firebase:firebase-iid:21.1.0"
Upvotes: 16
Reputation: 81
None of the answers above is correct. And none of them solves the problem. The problem is in transitive dependencies. You need to check which libs are causing the issue and do something like:
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation ('com.google.firebase:firebase-iid:21.1.0') {
transitive = true
}
Upvotes: 6
Reputation: 582
I resolved this problem by using the Firebase Android BoM
In my case the problem depends on the coexistence of messaging and functions.
So from this:
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation 'com.google.firebase:firebase-functions-ktx:20.0.0'
To this:
implementation platform('com.google.firebase:firebase-bom:28.2.1')
implementation 'com.google.firebase:firebase-functions-ktx'
implementation 'com.google.firebase:firebase-messaging'
Upvotes: 5
Reputation: 29
I encountered the same problem.
I fixed it by redefining my dependencies implementations like this:
In build.gradle:
implementation 'com.google.firebase:firebase-analytics:19.0.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-messaging:22.0.0'
Please note my configuration in buildscript: com.android.tools.build:gradle:4.2.1
Then, clean and rebuild project.
Can you share more information about your setup?
Upvotes: 2