3

i'm learning Android while doing some work on it. I'm trying to update an app's version to Android 8.0, that includes sdk, libraries and external APIs used.

I looked it up and it seems like 15.0.1 is the suggested version. But when i use it, gradle fails for play-services-analytics and firebase services to sync saying it cannot resolve the library and nor can it find the Repository if i press Install Repository.

Error Sample

So currently i'm using version 12.0.1 for both play services and firebase services. Using it like:

implementation 'com.google.android.gms:play-services-maps:12.0.1'
implementation 'com.google.android.gms:play-services-analytics:12.0.1'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.google.firebase:firebase-analytics:12.0.1'
implementation 'com.google.firebase:firebase-crash:12.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'

But if i try to use only the play-services 15.0.1 except for analytics then it gives me another warning that using different versions of play services and firebase services can lead to runtime crashes.

enter image description here

So it puts me in a weird situation, i've googled and searched, but cant find anything that works for me... What would be the correct way to deal with this here? Should i settle for 12.0.1? or update what ever works? (Previously the version was 9.4.0 or something along that line; before i was doing the Android 8.0 upgrade)

EDIT: These are my top level gradle dependencies

classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.2'

1 Answers1

6

You cannot mix versions of firebase and google play services that are less than or equal to 12 with versions that are greater than or equal to 15.

Therefore you need to update the version number of all these libraries:

implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-analytics:15.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-analytics:16.0.1'
implementation 'com.google.firebase:firebase-crash:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'

Check this:

https://firebase.google.com/support/release-notes/android

https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html

Beginning with version 15, each Maven dependency matching com.google.android.gms:play-services-* and com.google.firebase:firebase-* is no longer required to have the same version number in order to work correctly at build time and at run time.

Also use the following google play services plugin in the top level gradle file:

 classpath 'com.google.gms:google-services:4.0.1'
Peter Haddad
  • 78,874
  • 25
  • 140
  • 134