I’ve recently upgraded my Flutter version to the newest one (3.27.1). Everything works fine when I run the app directly through IDE. But when I tried to build my app’s APK for deployment, it doesn’t work. This is the error that I’ve been getting.
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 the │
│ version number of the plugin with id "org.jetbrains.kotlin.android" in the plugins block of │
│ <the location of my settings.gradle> │
│ │
│ Alternatively (if your project was created before Flutter 3.19), update │
│ <the location of my build.gradle> │
│ ext.kotlin_version = '<latest-version>'
For my case, my project was created before Flutter 3.19, so I followed the latter option. My initial kotlin_version is 1.9.0. I changed the ext.kotlin_version to 2.1.0 (The current newest version). It then tells me to upgrade my gradle version as well, so I did. But after all that, the same error appeared telling me to upgrade my kotlin version. I tried downgrading to 1.9.22 as well but still it didn’t work.
Any help would be greatly appreciated. Thanks.
2
Answers
Update Kotlin Version:
Make sure your ext.kotlin_version in android/build.gradle is updated to the latest stable version (e.g., 1.9.10 or the latest listed on the Kotlin Releases Page).
Example:
Upgrade Gradle Version:
Update your Gradle wrapper to match the Kotlin plugin requirements. Open android/gradle/wrapper/gradle-wrapper.properties and ensure you use the latest Gradle version (e.g., 8.1.1).
Update Gradle Plugin Version:
In android/build.gradle, update the Gradle plugin version under classpath.
Sync and Rebuild:
After making the updates, perform a Gradle sync and rebuild the project.
Clear Caches and Reinstall:
If the issue persists, try clearing the Gradle cache and reinstalling
Validate Flutter Environment:
Make sure your Flutter and Dart SDKs are updated.
┌─ 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 the │
│ version number of the plugin with id "org.jetbrains.kotlin.android" in the plugins block of │
│ D:Android applicationnews_appandroidsettings.gradle. │
│ │
│ Alternatively (if your project was created before Flutter 3.19), update │
│ D:Android applicationnews_appandroidbuild.gradle │
│ ext.kotlin_version = ” │
└──────────────────────────────────────────────
if i run the project to show me this type of error . my flutter version is 3.27.1
after changing the kotlin = 1.9.10 , still the error .