Problem
Flutter 3.44 / Android Gradle Plugin 9+ deprecated the standalone Kotlin Gradle Plugin (KGP) in favour of AGP's built-in Kotlin support (android.builtInKotlin=true, the default on AGP 9+).
This plugin currently applies kotlin-android unconditionally in its Android build file, e.g.:
apply plugin: 'kotlin-android'
Apps on AGP 9+ work today because the Flutter tool temporarily adds android.builtInKotlin=false as a compatibility shim (flutter/flutter#181383), but this shim is scheduled for removal before AGP 10. When removed, any plugin still applying kotlin-android unconditionally will break the Android build.
Suggested fix
Guard the apply with an AGP version check, the same pattern used by device_info_plus, package_info_plus, and share_plus:
// build.gradle.kts
val agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.split(".").first().toInt()
if (agpMajor < 9) {
apply(plugin = "org.jetbrains.kotlin.android")
}
Groovy equivalent:
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.split("\\.")[0].toInt()
if (agpMajor < 9) {
apply plugin: 'kotlin-android'
}
References
Problem
Flutter 3.44 / Android Gradle Plugin 9+ deprecated the standalone Kotlin Gradle Plugin (KGP) in favour of AGP's built-in Kotlin support (
android.builtInKotlin=true, the default on AGP 9+).This plugin currently applies
kotlin-androidunconditionally in its Android build file, e.g.:Apps on AGP 9+ work today because the Flutter tool temporarily adds
android.builtInKotlin=falseas a compatibility shim (flutter/flutter#181383), but this shim is scheduled for removal before AGP 10. When removed, any plugin still applyingkotlin-androidunconditionally will break the Android build.Suggested fix
Guard the apply with an AGP version check, the same pattern used by
device_info_plus,package_info_plus, andshare_plus:Groovy equivalent:
References