I'm encountering a Kotlin version mismatch error while building my Flutter Android project. The error indicates that the firebase-auth library is compiled with Kotlin 2.1.0, but my project is expecting Kotlin 1.9.0.
Here's the exact error message: e: file:///Users/phearum/.gradle/caches/8.10/transforms/9dea41008671cf73e36802b61d2139f3/transformed/jetified-firebase-auth-23.2.0/jars/classes.jar!/META-INF/java.google.android.gmscore.integ.client.firebase-auth-api_firebase-auth-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.9.0.
What I've Tried:
Kotlin Gradle Plugin Updates: I've updated the Kotlin Gradle plugin in my android/settings.gradle file. I've attempted multiple versions, including 2.1.0, and other recent versions, but the error persists.
Gradle Updates: I've updated my Gradle version. I've tried multiple recent versions (e.g., 8.0, 8.5), updating the distributionUrl in android/gradle/wrapper/gradle-wrapper.properties. I made sure to resync the project after each gradle change.
Clean and Rebuild: I've performed a flutter clean, cd android && ./gradlew clean, and rebuilt the project numerous times after each change.
Invalidate Caches: I've invalidated caches in Android Studio multiple times."
I'm encountering a Kotlin version mismatch error while building my Flutter Android project. The error indicates that the firebase-auth library is compiled with Kotlin 2.1.0, but my project is expecting Kotlin 1.9.0.
Here's the exact error message: e: file:///Users/phearum/.gradle/caches/8.10/transforms/9dea41008671cf73e36802b61d2139f3/transformed/jetified-firebase-auth-23.2.0/jars/classes.jar!/META-INF/java.google.android.gmscore.integ.client.firebase-auth-api_firebase-auth-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.9.0.
What I've Tried:
Kotlin Gradle Plugin Updates: I've updated the Kotlin Gradle plugin in my android/settings.gradle file. I've attempted multiple versions, including 2.1.0, and other recent versions, but the error persists.
Gradle Updates: I've updated my Gradle version. I've tried multiple recent versions (e.g., 8.0, 8.5), updating the distributionUrl in android/gradle/wrapper/gradle-wrapper.properties. I made sure to resync the project after each gradle change.
Clean and Rebuild: I've performed a flutter clean, cd android && ./gradlew clean, and rebuilt the project numerous times after each change.
Invalidate Caches: I've invalidated caches in Android Studio multiple times."
2 Answers
Reset to default 0just downgrade your firebase-auth version to 23.1.0 in your gradle and sync
implementation("com.google.firebase:firebase-auth:23.1.0")
Upgrade to Kotlin 2.1.10
; Android Studio provides a migration wizard, which fixes most differences in between these versions, which are generally not that much different to use.
There still might be minor refactoring required, but it can be done.
Gradle would be currently at version 8.12
, or something alike that.
I just find it strange, that it reads "jetified" there, which usually makes no sense anymore, unless building against Android "support libraries" a few years old, which aren't within the AndroidX namespace yet. I'd suggest to disable the Jetifier, in case it's not required anymore.
In terms of FlutterFire, in case this is being used, this might be version 5.5.1
.
When downgrading, probably this version is what needs to be downgraded;
but usually, upgrading should be preferred over downgrading, when possible.
If you think it's a defect, just file an issue on the issue tracker;
while such version conflicts commonly stem from the project.