Skip to content

Commit 82739e2

Browse files
4akloonclaude
andcommitted
fix(network_info_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) <noreply@anthropic.com>
1 parent 13e1704 commit 82739e2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/network_info_plus/network_info_plus/android/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ plugins {
2828

2929
val agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.substringBefore('.').toInt()
3030

31-
if (agpMajor < 9) {
31+
// AGP 9 provides Kotlin support natively unless the consuming app opts out with
32+
// android.builtInKotlin=false, which is what `flutter create` writes by default.
33+
val builtInKotlinEnabled =
34+
agpMajor >= 9 &&
35+
(providers.gradleProperty("android.builtInKotlin").orNull?.toBoolean() ?: true)
36+
37+
if (!builtInKotlinEnabled) {
3238
apply(plugin = "org.jetbrains.kotlin.android")
3339
}
3440

0 commit comments

Comments
 (0)