Fisher
Fisher

Reputation: 509

Android Gradle: All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes)

I'm trying to integrate Firebase Performance SDK. It occurs this conflict on this line (marked red line by Analysis) and crash after launch the app:

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

All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 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.

I've searched and tried the related questions/answers of this similar title but no one can work.

The dependencies are listed below. Before I used all version 11.8.0 working well. Performance SDK wants me to use firebase-perf:16.2.3 and it start this problem. Even though I modify all of them to 16.x.x, it still con't be fixed. I wonder whether it needs all of them in all the same subversion? But It can't be done for I've tried many of them lack a lot of subversions. For example if using all version 16.0.0, Some of them will occur "Failed to resolve:...".

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(Project: 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
}

Upvotes: 1

Views: 1765

Answers (2)

Fisher
Fisher

Reputation: 509

After trying a lot of hours, it happens to work on the following modifications. Especially the "(", ")" are needed for 'com.google.android.gms:play-services-ads:16.0.0', otherwise the conflict will not disappear!

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

Upvotes: 1

Juan Franco
Juan Franco

Reputation: 309

If you are using Android Studio: once the Gradle file is opened you should be able to see that some libraries are marked in yellow, if you hover the mouse over them a popup shows which are the latest version so you can start by replacing all of them with the latest version. After that cleaning and rebuilding the project could help.

Upvotes: 1

Related Questions