firebase / firebase-android-sdk

Firebase Android SDK
https://firebase.google.com
Apache License 2.0
2.22k stars 561 forks source link

Error: All gms/firebase libraries must use the exact same version specification [GradleCompatible] #5972

Closed Anigif closed 1 week ago

Anigif commented 4 weeks ago

Describe your environment

Describe the problem

After bumping to Firebase BoM we get this error for three of our modules (but not all of our modules) when running lintDebug:

Error: All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 21.0.0, 2.0.0, 19.0.0, 18.3.0, 18.1.0, 18.0.2, 18.0.1, 18.0.0, 17.1.1, 17.0.0, 16.2.0, 16.0.0. Examples include com.google.firebase:firebase-common-ktx:21.0.0 and com.google.firebase:firebase-sessions:2.0.0 [GradleCompatible]

      implementation platform("com.google.firebase:firebase-bom:$firebase_bom_version")
                               ~~~~~~~~~~~~~~~~~~~

     Explanation for issues of type "GradleCompatible":
     There are some combinations of libraries, or tools and libraries, that are
     incompatible, or can lead to bugs. One such incompatibility is compiling
     with a version of the Android support libraries that is not the latest
     version (or in particular, a version lower than your targetSdkVersion).

We are using Firebase BoM, various Firebase libraries (for instance perf, crashlytics and analytics) and a few gms-libraries that might be related.

This seems like an issue/question that might be more relevant for Stack Overflow, but we believe it might be an bug - or at least there's room for improvements in the error message. For instance:

And just for clarity firebase-common-ktx and firebase-sessions aren't libraries we directly refer to, they are transitive dependencies.

Steps to reproduce:

Unfortunately we don't have any reproducer at the moment and aren't able to share our code.

google-oss-bot commented 4 weeks ago

I found a few problems with this issue:

lehcar09 commented 4 weeks ago

Hi @Anigif, thank you for reaching out. I tried adding the same dependencies you shared and did the lintDebug, however, I did not encounter any error. Have you tried clearing your workspace cache and re-sync your Gradle files? It's possible that the dependencies are cached and causing compatibility issues.

If that doesn't work, could you share an build.gradle (app and project level) and libs.versions.toml file to help us investigate the issue?

twyatt commented 4 weeks ago

Simple reproducer: https://github.com/twyatt/firebase-android-sdk-bug

lehcar09 commented 4 weeks ago

Thanks for the MCVE @twyatt. Currently, Firebase does not yet officially support Kotlin Multiplatform. I suggest taking aa look at this unofficial SDK: gitliveapp/firebase-kotlin-sdk.

I'll go ahead and mark this as a feature request. While we are unable to promise any timeline for this, we'll definitely keep this under our radar. For folks who find this useful, adding an emoji thumbs up on the original post can help us prioritize adding this to the roadmap.

twyatt commented 4 weeks ago

@lehcar09 issue is not Kotlin Multiplatform specific. I've updated the simple reproducer and removed Kotlin Multiplatform. It is now a pure Android project, and issue still occurs.

brezenhem commented 4 weeks ago

I have the same problem after the update BoM 33.0.0 and com.google.gms:google-services: 4.4.1 And I don't have kotlin multiplatform on my project.

Anigif commented 3 weeks ago

Just for clarity, the project I'm working on is just Android as well. Looks like @twyatt shared a quite minimal reproducer, I hope that will be sufficient to figure out the cause. Some of the theories I've had (for instance that some libraries other than the ones provided by Firebase was using old versions) doesn't seem to be the problem.

I was also wondering if it was related to the change in -ktx not being needed anymore, but that didn't have any effect in our project either.

lehcar09 commented 3 weeks ago

Hi @Anigif, thank you for additional details. Could you share what Firebase BOM version you were using before version 33.0.0?

sindrenm commented 3 weeks ago

We're experiencing the same, and we were using 32.8.1 before version 33.0.0. 32.8.1 did not have the same issue.

lehcar09 commented 3 weeks ago

Thanks @sindrenm. I was able to reproduce the issue and confirm that the issue is not encountered in Firebase BOM version 32.8.1. I'll inform out engineers about this and see what we can here. Thanks!

ychescale9 commented 3 weeks ago

I'm able to workaround it by adding the latest version of com.google.firebase:firebase-measurement-connector to the classpath explicity:

implementation("com.google.firebase:firebase-measurement-connector:20.0.1")

your mileage may vary.

mrober commented 3 weeks ago

Simple reproducer: https://github.com/twyatt/firebase-android-sdk-bug

That is a nice min repo, thanks @twyatt. How did you not need an empty AndroidManifest file?

I have a fix for this, I am going to make sure it gets into the next release.

nicbell commented 3 weeks ago

Changing my implementation from:

    implementation platform(libs.firebase.bom)
    implementation libs.firebase.crashlytics.ktx

to

    implementation platform(libs.firebase.bom)
    implementation libs.firebase.crashlytics.ktx
    implementation libs.firebase.analytics.ktx

Fixed it for me, looks like the analytics library resolves the dependency correctly.

My TOML

firebase-bom = { module = "com.google.firebase:firebase-bom", version = "33.0.0" }
firebase-analytics-ktx = { module = "com.google.firebase:firebase-analytics-ktx" }
firebase-config-ktx = { module = "com.google.firebase:firebase-config-ktx" }
firebase-crashlytics-ktx = { module = "com.google.firebase:firebase-crashlytics-ktx" }
firebase-dynamic-links-ktx = { module = "com.google.firebase:firebase-dynamic-links-ktx" }
firebase-messaging-ktx = { module = "com.google.firebase:firebase-messaging-ktx" }
firebase-perf-ktx = { module = "com.google.firebase:firebase-perf-ktx" }
thatfiredev commented 2 weeks ago

The fix mentioned by @mrober was released in Crashlytics 19.0.1 (Firebase BoM 33.1.0): https://firebase.google.com/support/release-notes/android#crashlytics_v19-0-1