Firebase Core / Packages - Kotlin Version Incompatible with Flutter Project, Cannot Upgrade Successfully Due to Dependencies
Is there an existing issue for this?
- [x] I have searched the existing issues.
Which plugins are affected?
Core
Which platforms are affected?
Android
Description
I scanned the pub dev site and did not see any breaking changes. However, when I upgrade, my project will no longer build due to kotlin compiler issues.
They all reference play-services
e: .gradle/caches/8.8/transforms/649874752e14c87658151e5a9f9ecace/transformed/play-services-measurement-impl-22.2.0-api.jar!/META-INF/java.com.google.android.gms.libs.filecompliance.proto_file_access_api_type_kt_proto_lite.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.
e: .gradle/caches/8.8/transforms/649874752e14c87658151e5a9f9ecace/transformed/play-services-measurement-impl-22.2.0-api.jar!/META-INF/third_party.kotlin.protobuf.src.commonMain.kotlin.com.google.protobuf.kotlin_only_for_use_in_proto_generated_code_its_generator_and_tests.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.
e: .gradle/caches/8.8/transforms/649874752e14c87658151e5a9f9ecace/transformed/play-services-measurement-impl-22.2.0-api.jar!/META-INF/third_party.kotlin.protobuf.src.commonMain.kotlin.com.google.protobuf.kotlin_shared_runtime.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.
e: .gradle/caches/8.8/transforms/a11baf267683cf6a80d0c620b3a65d05/transformed/play-services-measurement-api-22.2.0-api.jar!/META-INF/java.com.google.android.gmscore.integ.client.measurement_api_measurement_api.kotlin_moduleModule was compiled with an incompatible version of Kotlin. The binary version of its metadata is 2.1.0, expected version is 1.8.0.
FAILURE: Build failed with an exception.
The common thread: "The binary version of its metadata is 2.1.0, expected version is 1.9.0."
I then tried to upgrade to kotlin 2 and I think it broke other dependencies so I reverted.
Reproducing the issue
I am using Flutter 3.27.3 Trying to build Android app. Latest update to firebase packages results in failed build.
Using the following remains successful:
firebase_auth: ^5.4.1
firebase_core: ^3.10.1
firebase_messaging: ^15.2.1
But upgrading to these will cause exception:
Package Name Current Upgradable Resolvable Latest
direct dependencies:
firebase_auth *5.4.1 5.4.2 5.4.2 5.4.2
firebase_core *3.10.1 3.11.0 3.11.0 3.11.0
firebase_messaging *15.2.1 15.2.2 15.2.2 15.2.2
I tried to upgrade Kotlin to 2, and jvm to 0.9.0, but then other packages do not build. Therefore, I had to revert.
Is this not considered a breaking change?
Firebase Core version
3.11.0
Flutter Version
3.27.3
Relevant Log Output
Flutter dependencies
Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.
Additional context and comments
I tried raising kotlin to 2.1.10 in settings.gradle, and both root and app level build.gradle.
But then things like R8 fail to build, and about a dozen other packages that were built with 1.9.
Hi @corepuncher, I'm unable to reproduce this issue. Kindly create a new flutter project which reproduces this issue and share the repo link here.
Hi @corepuncher, I'm unable to reproduce this issue. Kindly create a new flutter project which reproduces this issue and share the repo link here.
I actually just figured it out.
- Your latest firebase packages now use Kotlin 2.
- R8/AGP 8.3.1 was only able to understand 2.0.X, but I had modified my build.gradles to use 2.1.10.
- I went down to 2.0.21, and also deleted android/.gradle and ~/.gradle/caches
Cleaned, rebuilt, and now no errors. Maybe that'll help someone else out.
Can you share the changes?