Android gms.google.services version (15.0.1) confl

2019-06-06 16:43发布

问题:

Similar questions have been asked a lot here and I have gone through all of what I can find and tried all of the solutions there.

The Problem

"All GMS/Firebase must use the exact same version" - I can see that there is a version conflict for the following Google Services libraries, which arent specifically written on any of the build.gradle files, against version 16.0.0 of the firebase core library:

  • com.google.android.gms:play-services-ads-identifier-15.0.1
  • com.google.android.gms:play-services-base-15.0.1
  • com.google.android.gms:play-services-basement-15.0.1
  • com.google.android.gms:play-services-measurement-base-15.0.4
  • com.google.android.gms:play-services-stats-15.0.1

Here is my project level build.gradle and here is my app level build.gradle. As you can see, the error message comes from the firebase core dependency.

What I have done so far to check for existing Stack Overflow questions and solutions (mods, please review these attempts before saying that this question is a duplicate):

  1. This SO question provides a solution to make sure the latest Google Repository is installed under SDK Tools / Support Repository. Mine is the latest at version 58.
  2. The solution to this SO question and this was to increase the Firebase version to match the Google Services version. However, mine is the other way around (firebase version is higher than Google Services version). So when I try to downgrade the firebase version to the Google Services version, I get this error. However, I dont know how to upgrade the Google Services version because I have already upgraded the Google Services SDK tool to the latest and what I have added on the project level build.gradle (4.0.1) is the latest version as of today from Google's documentation.
  3. The solution to this SO problem was to keep all firebase dependency versions the same. I have only added one dependency so far (ie firebase-core) so it doesnt apply here.
  4. This one and this one says make sure to add apply plugin: 'com.google.gms.google-services' at the end of the app level build.gradle. I have already done that.

回答1:

Try to update everything you have. Start from your SDK Manager, Android Studio, etc. Try to use 28 as targetSdkVersion, compileSdkVersion, and also update Android Studio Gradle Tools (also in your dependency) to the latest version.

Then rebuild your project.



回答2:

The guidance on keeping all versions the same is no longer correct. See https://developers.google.com/android/guides/releases#may_2_2018 and https://developers.google.com/android/guides/versioning#remove_old_anti-pattern

Basically, with the 15.0.0 and above versions of Google Play services and Firebase libraries, you no longer have to keep all dependencies at the same version, and in fact different libraries may not all have the same version available.

In addition, the Google Repository in the Android Studio SDK Manager is no longer updated. You should use Google's Maven repository instead (https://developer.android.com/studio/build/dependencies#google-maven)