I’m developing a Flutter application in Android Studio. After upgrading the Flutter version from around 2.8 to 3.19.5, the Android build on a physical device no longer works.
The error is as follows:
e: /Users/shun/.gradle/caches/modules-2/files-2.1/androidx.lifecycle/lifecycle-common/2.7.0/85334205d65cca70ed0109c3acbd29e22a2d9cb1/lifecycle-common-2.7.0.jar!/META-INF/lifecycle-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: /Users/shun/.gradle/caches/transforms-3/b268270c5f07ae84179bbcf92aab4c93/transformed/jetified-savedstate-1.2.1/jars/classes.jar!/META-INF/savedstate_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: /Users/shun/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.24/9928532f12c66ad816a625b3f9984f8368ca6d2b/kotlin-stdlib-1.9.24.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
e: /Users/shun/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.24/9928532f12c66ad816a625b3f9984f8368ca6d2b/kotlin-stdlib-1.9.24.jar!/META-INF/kotlin-stdlib-jdk8.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
e: /Users/shun/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.9.24/9928532f12c66ad816a625b3f9984f8368ca6d2b/kotlin-stdlib-1.9.24.jar!/META-INF/kotlin-stdlib-jdk7.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.6.0.
┌─ Flutter Fix
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update /Users/shun/Downloads/workspace/mirre/android/build.gradle: │
│ ext.kotlin_version = '<latest-version>' │
└─────────────────────────────────────────────────────────────────────────
android/build.gradle file with:
buildscript {
ext.kotlin_version = '1.9.24'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.8'
classpath 'com.google.firebase:perf-plugin:1.4.1'
}
}
flutter doctor is as follows:
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.5 23F79 darwin-arm64 (Rosetta), locale ja-JP)
• Flutter version 3.19.5 on channel stable at /Users/shun/Downloads/workspace/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 300451adae (9 weeks ago), 2024-03-27 21:54:07 -0500
• Engine revision e76c956498
• Dart version 3.3.3
• DevTools version 2.31.1
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0-rc1)
• Android SDK at /Users/shun/Library/Android/sdk
• Platform android-34-ext8, build-tools 35.0.0-rc1
• ANDROID_HOME = /Users/shun/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
???? https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
???? https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
[✓] VS Code (version 1.89.1)
• VS Code at /Users/shun/Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.88.0
[✓] Connected device (6 available)
• M2101K6G (mobile) • 63397ca9 • android-arm64 • Android 13 (API 33)
• shun's iPad (mobile) • 00008030-001944DE3682202E • ios • iOS 17.4.1 21E236
• shun's (mobile) • 00008120-000A308A1103C01E • ios • iOS 17.4.1 21E236
• iPhone 15 Pro (mobile) • A21A87ED-90BB-4062-B92F-D76D7F68ED0C • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64 (Rosetta)
• Chrome (web) • chrome • web-javascript • Google Chrome 125.0.6422.78
[✓] Network resources
• All expected network resources are available.
• No issues found!
Articles suggest that changing the build.gradle file should resolve the issue, but I’m not using Kotlin version 1.6.0 anywhere in my project, which is causing confusion.
I tried change the kotlin version in android/ build.gradle,,,
but,it couldnt read the project,,
Shun Kikuchi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.