From 4ff9bc5a0cff24f022c7e0610635abd021c3850a Mon Sep 17 00:00:00 2001 From: Yevhenii Aleksiuk Date: Fri, 31 Jul 2026 10:18:15 +0200 Subject: [PATCH] fix(android_alarm_manager_plus): apply KGP unless built-in Kotlin is enabled The guard assumed AGP 9 always means built-in Kotlin is active. AGP enables built-in Kotlin only when android.builtInKotlin is not explicitly false, and `flutter create` writes android.builtInKotlin=false into every new app. On AGP 9 with android.builtInKotlin=false, the plugin skipped KGP and AGP provided no Kotlin either, so nothing compiled the plugin's Kotlin sources and configuration failed at the KotlinAndroidProjectExtension lookup. This was masked only because Flutter's kgpRegexKotlin does not match the imperative apply(plugin = "...") form, so Flutter applied KGP as a fallback on the plugin's behalf. Guard on the same condition AGP itself uses: built-in Kotlin is on when AGP >= 9 and android.builtInKotlin is not explicitly false. Co-Authored-By: Claude Opus 5 (1M context) --- .../android_alarm_manager_plus/android/build.gradle.kts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/android_alarm_manager_plus/android/build.gradle.kts b/packages/android_alarm_manager_plus/android/build.gradle.kts index 7b642572ee..aab02b1538 100644 --- a/packages/android_alarm_manager_plus/android/build.gradle.kts +++ b/packages/android_alarm_manager_plus/android/build.gradle.kts @@ -28,7 +28,13 @@ plugins { val agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.substringBefore('.').toInt() -if (agpMajor < 9) { +// AGP 9 provides Kotlin support natively unless the consuming app opts out with +// android.builtInKotlin=false, which is what `flutter create` writes by default. +val builtInKotlinEnabled = + agpMajor >= 9 && + (providers.gradleProperty("android.builtInKotlin").orNull?.toBoolean() ?: true) + +if (!builtInKotlinEnabled) { apply(plugin = "org.jetbrains.kotlin.android") }