1

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
}
Fisher
  • 488
  • 7
  • 24
  • Pelase add the entire content of your build.gradle file. Please also add the other one. – Alex Mamo Feb 11 '19 at 16:17
  • You are using a very old version of the Play services plugin in the top level gradle file. Check that *everything* is up to date according to the documentation. https://firebase.google.com/docs/android/setup – Doug Stevenson Feb 11 '19 at 16:39
  • @Doug Stevenson, everything is up to date, except below two. But even I changed them up to date to 17.1.3, this error is still there. compile 'com.google.android.gms:play-services-ads:17.1.3' compile 'com.google.firebase:firebase-ads:17.1.3' – Fisher Feb 12 '19 at 05:33
  • Your play services plugin is WAY out of date. Latest is 4.2.0. You have 3.0.0. you're also list it a second time with another old version 4.0.2. – Doug Stevenson Feb 12 '19 at 14:19
  • @Doug Stevenson, Thanks! I remove the necessary classpath 'com.google.gms:google-services:3.0.0'. The same error is still there. And if I use 4.2.0, some other error appears as below. It seems not related with the original error. Error:Could not find com.google.android.gms:strict-version-matcher-plugin:1.1.0. Searched in the following locations: file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/android/gms/strict-version-matcher-plugin/1.1.0/strict-version-matcher-plugin-1.1.0.pom... – Fisher Feb 13 '19 at 05:38
  • Sounds like you don't have the google maven repo added to your buildscript. – Doug Stevenson Feb 13 '19 at 13:56
  • @Doug Stevenson, the google maven has been added before for firebase crashlytics. It's not listed in above code for it's obviously unrelated. – Fisher Feb 13 '19 at 15:08
  • I'm talking about the google maven *repository*, not the classpath dependency. You should probably re-read the setup documentation and check that you've added everything required. – Doug Stevenson Feb 13 '19 at 15:18
  • @Doug Stevenson, maven were added before in build.gradle(Project:). buildscript { repositories { jcenter() maven { url 'https://maven.fabric.io/public' //for crashlytics } } --- allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } } – Fisher Feb 14 '19 at 06:25
  • @Doug Stevenson, I've tried a solution as the answer below, though I don't know why. Maybe you can explain for us. – Fisher Feb 14 '19 at 09:57
  • I've never had to do what your answer is suggesting, nor have I ever heard of that being done. Without seeing your entire build.gradle files, it's not really possible to reproduce. – Doug Stevenson Feb 14 '19 at 10:10

2 Answers2

1

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.

Juan Franco
  • 199
  • 1
  • 7
  • all the libraries, which are marked yellow, are corrected in above attached code, except below tow lines. But even I update these two line up to date, the problem is still there. compile 'com.google.android.gms:play-services-ads:17.1.3' compile 'com.google.firebase:firebase-ads:17.1.3' – Fisher Feb 14 '19 at 04:21
  • Could you add the exact message that you receive now after updating all the versions? I'm using in a project those: 'com.google.android.gms:play-services-ads:17.1.2' and 'implementation 'com.google.firebase:firebase-core:16.0.6' and there are no conflicts. Maybe you don't need both ads libraries... – Juan Franco Feb 14 '19 at 06:32
  • the message is just on the original question: It occurs this error on this line (marked red by analysis): 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. – Fisher Feb 14 '19 at 06:52
1

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
Fisher
  • 488
  • 7
  • 24