Duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class

元气小坏坏 提交于 2019-11-30 09:02:51

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.

ֆɦɛӄɦǟʀ ֆʊʍǟռ

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
}
Jaime Montoya

In my case, I was using this in app/build.gradle:

compile 'com.google.android.gms:play-services-location:9.8.0'
compile 'com.google.android.gms:play-services-maps:9.8.0'

The error when I was trying to generate a Signed APK was:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class

I modified app/build.gradle by removing the two lines I mentioned above and using this instead:

compile 'com.google.android.gms:play-services:9.8.0'

Of course "play-services" is the full bundle and not an optimized way to do this. It would be best to specify the specific services that are required (read Does "play-services:9.8.0" include "play-services-location:9.8.0"?), but for now it fixes the error in my case.

java.util.zip.ZipException: duplicate entry: com/google/firebase/iid/zzb.class

follow this its work .remove your current google play service dependency and go to file in android Studio select module setting and the select dependency tab now click on + icon and select lib dependency after that search your play service in studio and add it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!