Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions packages/ndk_flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ allprojects {
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

// AGP 9+ bundles Kotlin (Flutter Built-in Kotlin); only apply KGP ourselves on older AGP.
// Must stay on one line: Flutter's detection flags any line starting with `apply plugin: 'kotlin-android'`.
def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
if (agpMajor < 9) { apply plugin: 'kotlin-android' }
Comment on lines +24 to +28

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

Does android.builtInKotlin=false gradle property require kotlin-android plugin in library subprojects on AGP 9?

💡 Result:

Yes, if you set android.builtInKotlin=false in your gradle.properties file, you are effectively disabling the built-in Kotlin support provided by the Android Gradle Plugin (AGP) 9.0 [1]. Consequently, you must apply the kotlin-android plugin in your library subprojects (and any other modules) to compile Kotlin code, as the built-in functionality is no longer active to handle that task [1][2]. The android.builtInKotlin=false flag is intended as a temporary opt-out mechanism for projects that cannot immediately migrate to AGP 9.0's built-in Kotlin support due to conflicts or specific configuration needs [1][2]. When this property is set to false, AGP reverts to the previous behavior where it relies on the separately applied kotlin-android plugin for Kotlin compilation [1]. You should remove this flag once you have resolved the underlying issues and migrated to built-in Kotlin [3][1]. In AGP 9.0, built-in Kotlin is enabled by default, which removes the need to apply the kotlin-android plugin manually in those modules [3][1].

Citations:


Honor the android.builtInKotlin=false escape hatch.
AGP 9+ only skips kotlin-android when built-in Kotlin is enabled; if a consumer opts out with android.builtInKotlin=false, this module still needs the plugin or Kotlin compilation will fail.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ndk_flutter/android/build.gradle` around lines 24 - 28, Update the
build logic in build.gradle so the Kotlin plugin is applied not only for AGP
versions below 9, but also whenever android.builtInKotlin is explicitly false.
Use the existing agpMajor check and the kotlin-android application block to add
a built-in Kotlin opt-out condition, ensuring this module still applies KGP when
a consumer disables Flutter built-in Kotlin.


android {
if (project.android.hasProperty("namespace")) {
Expand All @@ -35,10 +39,6 @@ android {
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = '17'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
Expand Down Expand Up @@ -67,6 +67,12 @@ android {
}
}

kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}

subprojects {
afterEvaluate { project ->
if (project.extensions.findByName("android") != null) {
Expand Down
Loading