重复条目:com / google / firebase / FirebaseApiNotAvailableException.class [英] Duplicate entry: com/google/firebase/FirebaseApiNotAvailableException.class
问题描述
尝试从8.4.0 => 9.2.0升级Play Services。
buildscript {
依赖关系{
classpath'com.google.gms: google-services:3.0.0'
...
依赖项{
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'
请注意, Firebase的任何地方。
自升级以来,我收到以下Gradle生成错误:
$ b
com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com / google / firebase / FirebaseApiNotAvailableException.class
我知道,Firebase捆绑在Google Play服务中(自9.0以来
但是我不能为了我的生活找出是什么原因造成的。
解决方案好的 - 罪魁祸首是React-Native。 / p>
提示是Gradle控制台上出现的这条不起眼的线条:
google -services插件无法检测任何版本的
com.google.android.gms或com.google.firebase,默认版本:9.0.0
将被使用。
修正?通过将以下行添加到build.gradle中,强制RN库项目链接到正确的Firebase版本:
compile' com.google.firebase:firebase-core:9.2.1'
然后:
作为一个侧面说明,这个问题引发了我深入了解依赖关系管理。我已经写了一篇有关解决共同依赖问题的广泛文章。
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.
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.
这篇关于重复条目:com / google / firebase / FirebaseApiNotAvailableException.class的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!