Android | Cannot add all Google libraries for version 15.0.1 - android

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.
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.
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'

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'

Related

Android Studio Dependency 'androidx.browser:browser:1.4.0' requires 'compileSdkVersion' to be set to 31 or higher

currently my sdk version is 29.
I've added firebase imports in gradle and it works fine for the database and firestore.
But when I add the import for the firebase auth I get this error.
One or more issues found when checking AAR metadata values:
Dependency 'androidx.browser:browser:1.4.0' requires 'compileSdkVersion' to be set to 31 or higher.
Compilation target for module ':app' is 'android-29'
I've tried importing with no version (in firebase documentation firebase bom select the version automatic and I've tried setting the version to implementation 'com.google.firebase:firebase-auth:21.0.6' but I get the same error)
Here is a piece of my gradle file:
implementation platform('com.google.firebase:firebase-bom:30.1.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-auth'
The problem is the firebase-auth because if I comment the line of code the app runs fine
Fixed by setting the implementation of firebase bom to the version of 29:
implementation platform('com.google.firebase:firebase-bom:29.3.1')

Android Gradle Libraries Conflict

I'm trying to implement Firebase dynamic links in an application that already uses Firebase, but once I added the needed libraries for dynamic links I started receiving this error:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[19.0.
2]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
these are the old dependencies related to Firebase that were previously used in the app:
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
and these are the new ones I'm trying to add:
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:26.0.0')
// Declare the dependencies for the Dynamic Links and Analytics libraries
// When using the BoM, you don't specify versions in Firebase library dependencies
implementation 'com.google.firebase:firebase-dynamic-links-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
I'm not sure which dependency the error is referring to that need to be updated.
If you're going to use the Firebase BoM:
implementation platform('com.google.firebase:firebase-bom:26.0.0')
you should specify all of your Firebase depedencies without version numbers, and let the BoM assign them, so that they are all compatible with each other. This means stripping off the version numbers for the dependencies you added for FCM and others:
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-database'
implementation 'com.google.firebase:firebase-core'
implementation 'com.google.firebase:firebase-ml-vision'
I don't know about 'com.google.android.gms:play-services-auth:17.0.0' - you might have to make sure that one is manually up to date to the latest version.

Firebase + Google Play Services = Error: "com.google.android.gms:play-services-basement ... [[15.0.1,15.0.1]], but resolves to 16.0.1"

I was getting my own version of the following error using vanilla Android (no React voodoo), and the other hacky solutions, namely this one, didn't work for me, so I'm posting what did.
After implementing firebase-core
implementation 'com.google.firebase:firebase-core:16.0.1'
in my Android project that was currently using
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
for Google Play location services, I got the following error:
The library com.google.android.gms:play-services-basement is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 16.0.1
I just changed the lines in my app/build.gradle:
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
to
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
and did a Build > Clean Project

The application is getting crashed after upgrade the Google Play Service version from 11.2.2 to 15.0.0

The application is getting crashed after upgrade the Google Play Service version from 11.2.2 to 15.0.0 with the following error
compile 'com.google.android.gms:play-services-auth:15.0.0'
compile 'com.google.android.gms:play-services-ads:15.0.0'
compile 'com.google.android.gms:play-services-location:15.0.0'
compile 'com.google.android.gms:play-services-base:15.0.0'
compile 'com.google.firebase:firebase-messaging:15.0.0'
Error Stacktrace:
Fatal Exception: java.lang.AbstractMethodError: abstract method "void com.google.firebase.iid.zzb.zzd(android.content.Intent)"
at com.google.firebase.iid.zzc.run(Unknown Source:4)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:7)
at java.lang.Thread.run(Thread.java:764)
AbstractMethodError is throw if you try to call an abstract method without an implementation, which is normally checked at compile time.
This can be caused by things like incompatible library versions, but you have everything at 15.0.0 so that should be fine. I would suggest trying to do a clean build (e.g. ./gradlew clean) just in case there is something that isn't being recompiled correctly.
You might also need to upgrade current version of Google Play Services that your studio uses from SDK Manager.
Go to Tools->SDK Manager->SDK tools->Check if there's any update available for Google Play Services
Hope this helps.
This is happend because you should use the latest version like below (based on this link):
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
Also make sure that you app gradle classpath be like:
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
If you are using com.google.android.gms check to be to the latest version too (based on this link):
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'

Failed to resolve implementation 'com.google.firebase:firebase-messaging:15.0.2'

I am integrating Firebase messaging for a version. It is:
'com.google.firebase:firebase-messaging:15.0.2'
My classpath is:
classpath 'com.google.gms:google-services:3.2.0'
I had faced the following error:
Failed to resolve: firebase-messaging Open File
Change this:
classpath 'com.google.gms:google-services:3.2.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
into this:
classpath 'com.google.gms:google-services:4.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
Explanation:
Here in this case using firebase-messaging:15.0.2 with google-services:4.0.1 would work, since the most important thing was updating google-services above 3.2.0, and that's because google-services:3.3.0 is needed to be able to use the firebase library from version 15.0 and above. You can check this blog post. that explains the changes in versioning of firebase libraries.
But it is still better to update the google-services plugin to prevent any other errors with other dependencies.
Note:
The versions less than 15.0.0 are in google maven repository, so you can use them in gradle. But, you cannot mix version 15.0.0 with a version less than 15.0.0 and use google play services 4.0.1, as said in my answer here. That's why it is better to update firebase libraries to the latest versions.
According to the Guy4444 1 on the post 2 I have changed
implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'
to
implementation 'com.google.firebase:firebase-messaging:17.0.0'
and it solved the problem!
I got it resolved by changing
this
implementation 'com.google.firebase:firebase-messaging:17.0.0:15.0.0'
to this
implementation 'com.google.firebase:firebase-messaging:17.0.0'

Categories

Resources