You upgrade the Android Gradle Plugin (AGP) to 9.x, or upgrade to Flutter 3.50, whose new projects use AGP 9.3.1. Then the Android build stops with one of these Gradle errors:
Failed to apply plugin 'org.jetbrains.kotlin.android'.
> Cannot add extension with name 'kotlin', as there is an extension already registered with that name.
> The 'org.jetbrains.kotlin.android' plugin is no longer required for Kotlin support since AGP 9.0.
When the build runs through the Flutter tool, Flutter recognises the second one and prints its own box. This is the text from the Flutter 3.50 tool source:
Starting AGP 9+, the default has become built-in Kotlin.
This results in a build failure when applying the kotlin-android plugin.
To resolve this, migrate to built-in Kotlin.
Why it happens
Before AGP 9, Android apps compiled Kotlin with a separate plugin, the Kotlin Gradle plugin, applied as kotlin-android or org.jetbrains.kotlin.android. AGP 9 has Kotlin support built in and turns it on by default. If your app or one of its Flutter plugins still applies kotlin-android, the two clash and the build fails.
Most Flutter apps and plugins still apply kotlin-android. So Flutter (from 3.44) keeps built-in Kotlin off for now. Every time you run flutter run or flutter build, a Flutter migration adds these lines to android/gradle.properties if they aren’t there:
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=false
# This newDsl flag was added automatically by Flutter migrator
android.newDsl=false
That’s why you usually see this error in one of these cases:
- You opened the
androidfolder in Android Studio and synced Gradle, or ran./gradlewdirectly, before ever running a Flutter build on the new AGP. - Someone set
android.builtInKotlin=truewhile the app or a plugin still applieskotlin-android. - It’s an add-to-app project, where the Flutter tool doesn’t manage the host app’s
gradle.properties.
Fix 1: turn built-in Kotlin off (works today)
Open android/gradle.properties and make sure both lines are there:
android.builtInKotlin=false
android.newDsl=false
Then:
flutter clean
flutter run
Leave android.newDsl=false in as well. The kotlin-android plugin doesn’t work with AGP 9’s new DSL, and Flutter’s own Gradle plugin still reads the old DSL. If you remove it, the build fails with a java.lang.NullPointerException (no error message) while applying the Flutter Gradle plugin. Flutter catches that one too and tells you to “opt out of android.newDsl”.
This is the setup Flutter 3.50 itself uses: flutter create on 3.50 writes android.builtInKotlin=false and android.newDsl=false into every new project.
Fix 2: migrate your app to built-in Kotlin
The opt-out is temporary. Google’s AGP docs say you won’t be able to turn built-in Kotlin off in AGP 10.0. Your own app module can move now. In android/app/build.gradle.kts, remove the Kotlin plugin line:
plugins {
id("com.android.application")
id("kotlin-android") // remove this line
id("dev.flutter.flutter-gradle-plugin")
}
In Groovy (android/app/build.gradle) the line to remove is apply plugin: 'kotlin-android' or id "kotlin-android".
Then replace the old kotlinOptions block inside android { }:
android {
kotlinOptions { // remove this block
jvmTarget = JavaVersion.VERSION_17.toString()
}
}
with a top-level kotlin { } block, which is exactly what the Flutter 3.50 template has:
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}
Keep id("org.jetbrains.kotlin.android") version "..." apply false in android/settings.gradle.kts for now. The 3.50 template still has it (version 2.4.20), because Flutter plugins that apply kotlin-android need it.
Can I set android.builtInKotlin=true?
Only when every Flutter plugin in your app has migrated too, and on Flutter 3.47 or later. One plugin that still applies kotlin-android brings the original error back.
To check a plugin, open its pub.dev page and look for “Migrates to built-in Kotlin” in the changelog. If it isn’t there, keep the flag at false, and pin or replace the plugin later. The Flutter package checker shows which packages in your pubspec are behind or discontinued.
Related version errors
AGP 9 also raises the minimum Gradle and Kotlin versions. Flutter 3.50 stops the build below AGP 9.1.1, Gradle 9.3.1 or Kotlin 2.4.10. Those errors are covered in “Requires a newer version of the Kotlin Gradle plugin” and “Unsupported class file major version”. The Gradle and target API checker reads your Gradle files and lists the versions to move to.
Frequently asked questions
What does "kotlin.android plugin is no longer required since AGP 9.0" mean?
AGP 9 compiles Kotlin itself (built-in Kotlin), so applying the separate kotlin-android plugin now fails. Either set android.builtInKotlin=false and android.newDsl=false in android/gradle.properties, or remove kotlin-android from the app module and migrate to built-in Kotlin.
Does Flutter support AGP 9?
Yes. Flutter 3.44 added AGP 9 support with built-in Kotlin turned off through android.builtInKotlin=false, and new Flutter 3.50 projects use AGP 9.3.1. Turning built-in Kotlin on needs Flutter 3.47 or later and plugins that have migrated.
Why does the error only appear in Android Studio?
The Flutter tool adds android.builtInKotlin=false and android.newDsl=false to gradle.properties when you run flutter run or flutter build. A Gradle sync in Android Studio, or ./gradlew, doesn’t run that migration. Run a Flutter build once, or add the two lines yourself.
Is android.builtInKotlin=false safe to ship with?
Yes. It’s the default in new Flutter 3.50 projects. It is temporary, though: Google says built-in Kotlin can’t be turned off in AGP 10.0, so migrate your app module now and your plugins as they publish updates.
Stuck on a build or a store release? I fix and maintain Flutter apps, or tell me about your project. More fixes: all Flutter answers.