Skip to content
DeveloperMemos

Fixing the Kotlin Gradle Plugin Version Error in Flutter

Flutter, Kotlin, Android, Troubleshooting, Mobile Development1 min read

Recently ran into that pesky Kotlin Gradle plugin error in your Flutter project? Yeah, me too. It's one of those head-scratching moments when you're ready to build your app and Flutter throws this at you:

1┌─ Flutter Fix ──────────────────────────────────────────────────────────────────────────────────────────┐
2│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
3│ Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update the │
4│ version number of the plugin with id "org.jetbrains.kotlin.android" in the plugins block of │
5│ /Users/johnsmith/FlutterProjects/test_app/android/settings.gradle. │
6│ │
7│ Alternatively (if your project was created before Flutter 3.19), update │
8│ /Users/johnsmith/FlutterProjects/test_app/android/build.gradle │
9│ ext.kotlin_version = '<latest-version>' │
10└────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Don't worry – it's actually pretty simple to fix. Let me walk you through it.

Quick Fix Options

There are two ways to handle this, depending on when you created your Flutter project:

For Newer Projects (Flutter 3.19+)

Just pop open your android/settings.gradle file and update the Kotlin plugin version. Here's what you're looking for:

1plugins {
2 id 'org.jetbrains.kotlin.android' version '1.9.22' // Bump this to the latest version
3 // Your other plugins will be here
4}

For Older Projects (Pre-Flutter 3.19)

If you're working with an older project, you'll need to update android/build.gradle instead:

1buildscript {
2 ext.kotlin_version = '1.9.22' // Just update this line
3 // The rest of your buildscript block stays the same
4}

Getting the Latest Version

Head over to the Kotlin Releases Page and grab the latest stable version. Don't be tempted by the EAP (Early Access Preview) versions unless you really know what you're doing!

Making Sure It Worked

After updating the version, run these commands in order:

1flutter clean
2flutter pub get
3flutter run

Troubleshooting Tips

If you're still seeing red:

  1. Double-check you've updated the right file (easy to mix up build.gradle and settings.gradle)
  2. Clear out your build folder
  3. Wipe the Gradle cache if you're feeling thorough
  4. Try a fresh build

Pro Tips

  • Keep your Kotlin version in sync with your Android Studio version
  • Save yourself future headaches by updating Kotlin whenever you update Flutter
  • If you're working on a team, make sure everyone's using the same versions

That's really all there is to it! Hit me up in the comments if you run into any snags.

Remember: Always backup your project before messing with Gradle files. Trust me on this one.