Android Gradle:所有gms / firebase库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)

时间:2019-02-11 15:38:17

标签: android firebase gradle google-play-services

我正在尝试集成Firebase Performance SDK。在此行上发生此冲突(由Analysis标记为红线),并在启动应用程序后崩溃:

   compile 'com.google.android.gms:play-services-ads:16.0.0'

所有gms / firebase库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本17.1.0、17.0.5、17.0.3、17.0.1、16.3.0、16.2.3、16.2.1、16.1.0、16.0.7、16.0.3、16.0.1、16.0.0。

我已经搜索并尝试过与此类似标题相关的问题/答案,但是没有人可以工作。

依赖性在下面列出。在我使用所有版本11.8.0之前,它都运行良好。 Performance SDK希望我使用firebase-perf:16.2.3,它开始出现此问题。即使我将所有它们都修改为16.x.x,它仍然没有得到修复。我想知道它是否在所有相同的Subversion中都需要它们?但这是无法完成的,因为我尝试过其中许多缺乏很多颠覆性功能。例如,如果使用所有版本16.0.0,则其中一些将出现“无法解决:...”。

build.gradle(Module:app)

compile 'com.google.android.gms:play-services-ads:16.0.0'
compile 'com.google.firebase:firebase-core:16.0.7'
compile 'com.google.firebase:firebase-ads:16.0.1'
compile 'com.google.firebase:firebase-auth:16.1.0'
compile 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-config:16.3.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-perf:16.2.3'

build.gradle(项目:xxxx)

    dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'
    classpath 'com.google.gms:google-services:4.0.2'
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
    classpath 'io.fabric.tools:gradle:1.25.4'   //for crashlytics
    classpath 'com.google.firebase:firebase-plugins:1.1.5'  //for performance
}

2 个答案:

答案 0 :(得分:1)

如果您使用的是Android Studio:打开Gradle文件后,您应该能够看到某些库标记为黄色,如果将鼠标悬停在它们上方,则会弹出一个弹出窗口,显示最新版本,因此您可以从将它们全部替换为最新版本。之后,清理和重建项目可能会有所帮助。

答案 1 :(得分:1)

尝试了多个小时后,它可以进行以下修改。 尤其是'com.google.android.gms:play-services-ads:16.0.0'需要使用“(”,“)”,否则冲突不会消失!

compile ('com.google.android.gms:play-services-ads:16.0.0')

compile ('com.google.firebase:firebase-core:16.0.7'){exclude group: "com.google.android.gms"}
compile ('com.google.firebase:firebase-ads:16.0.1'){exclude group: "com.google.android.gms"}
compile ('com.google.firebase:firebase-auth:16.1.0'){exclude group: "com.google.android.gms"}
compile ('com.google.firebase:firebase-crash:16.2.1'){exclude group: "com.google.android.gms"}
implementation 'com.google.firebase:firebase-config:16.3.0'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-perf:16.0.0'  //if using 16.2.3, sometime the app crashes as soon as it starts. 
                                                       //Below post reported that some other bug from firebase-perf:16.1.0
                                                         //https://stackoverflow.com/a/51967966/8046317