Duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class
Solution 1
Well - the culprit is React-Native.
The hint was this obscure line that appears on the Gradle console:
google-services plugin could not detect any version for com.google.android.gms or com.google.firebase, default version: 9.0.0 will be used.
The fix? Force the RN library project to link with the correct Firebase version, by adding the following line to its build.gradle:
compile 'com.google.firebase:firebase-core:9.2.1'
And thus:
As a side-note, this issue has triggered me to look deeper into gradle dependency management. I've written an extensive post about resolving common dependency issues.
Solution 2
The problem is that you use both the plugins in the build.gradle file so remove the one Google Play Services plugin, like
apply plugin: 'com.google.gms.google-services'
and
compile 'com.google.android.gms:play-services:11.0.2'
So remove both of one library and then add
packagingOptions {
exclude 'META-INF/NOTICE' // It is not include NOTICE file
exclude 'META-INF/LICENSE' // It is not include LICENSE file
}
![Vaiden](https://i.stack.imgur.com/Z6uDY.jpg?s=256&g=1)
Comments
-
Vaiden about 2 years
I have an Android project built with React-Native and employing Google Play Services (analytics, cloud messaging, ads). I'm not explicitly using Firebase anywhere.
Tried upgrading the Play Services from 8.4.0 => 9.2.0. Also upgraded the GPS classpath.
buildscript { dependencies { classpath 'com.google.gms:google-services:3.0.0'
...
dependencies { compile 'com.google.android.gms:play-services-analytics:9.2.1' compile 'com.google.android.gms:play-services-ads:9.2.1' compile 'com.google.android.gms:play-services-base:9.2.1' compile 'com.google.android.gms:play-services-gcm:9.2.1'
Notice that I'm not explicitly depending on Firebase anywhere.
Ever since the upgrade I'm getting the following Gradle build error:
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class
I know that Firebase comes bundled within the Google Play Services (since 9.0), so I figured something else is compiling and linking with an older version. So looking at the dependency insight (
gradle -q dependencyInsight --configuration compile --dependency firebase
) I've noticed that firebase-common 9.0.0 is being added on top of 9.2.1:But I can't for the life of me find out what causes this.
-
SjoerdvGestel over 7 yearsi had a different issue, but this answer did the trick :) Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zza.class
-
mienaikoe over 7 yearsI had the same problem, but when I added firebase-core version 10.0.1, I was getting:
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/api/zze.class
Rolling the version back to 9.2.1 fixed it. Thank you for your post!