In flutter getting ** 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.**
After formatting the system installed Android Studio – Chipmunk | 2021.2.1 Patch 2
Kotlin version – 212-1.6.10-release-923-AS5457.46
Flutter version 3.7.3 and Dart version 2.19.2
Have tried
- Invalidating cache
- Cleaning gradle files
- In Android Studio, you can go to Build -> Clean Project
- flutter clean, flutter pub get
- Have also formatted the OS from the system and reinstalled
[✓] Flutter (Channel stable, 3.7.3, on macOS 12.6.6 21G646 darwin-x64, locale
en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.78.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
Detailed Step by step answer to resolve the issue
2
Answers
Change
kotlin
version to 1.6.0 or above inandroid/build.gradle
.kotlin-version https://docs.flutter.dev/release/breaking-changes/kotlin-version
We faced the same issue and our project was at a stand still for a whole week,
RCA:
The issue was caused because of the ^ we add in front of the flutter package versions. Due to which the pubspec.lock got modified with a latest version of the packages.
Solution:
We removed the ^ from the versions and followed below steps
this resulted in the pubspec.lock being generated again with the exact versions of the packages mentioned in the pubspec.yaml