diff --git a/android/build.gradle.kts b/android/build.gradle.kts index dbee657..0ce25a9 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -1,3 +1,10 @@ +plugins { + // Declared with apply false so the Kotlin Gradle Plugin classes (used below to fix up + // file_picker's Kotlin compilation) are resolvable from this script, without applying the + // plugin to the root project itself. Version matches settings.gradle.kts. + id("org.jetbrains.kotlin.android") version "2.3.20" apply false +} + allprojects { repositories { google() @@ -19,6 +26,28 @@ subprojects { project.evaluationDependsOn(":app") } +// file_picker's android/build.gradle guards `apply plugin: 'org.jetbrains.kotlin.android'` +// behind a runtime AGP-version check (skipped on AGP 9+, where it assumes AGP's built-in +// Kotlin support is active). Flutter's own auto-apply logic in FlutterPluginUtils only +// scans the file's text for that apply statement -- it matches even though the guard makes +// it a no-op on this project's AGP 9, so Flutter skips applying Kotlin itself too. With +// android.builtInKotlin=false (kept for compatibility with other plugins), no Kotlin plugin +// ever gets applied to file_picker, and its Kotlin sources (including FilePickerPlugin) never +// compile. Apply it explicitly here once AGP's library plugin is in place. +subprojects { + if (name == "file_picker") { + pluginManager.withPlugin("com.android.library") { + pluginManager.apply("org.jetbrains.kotlin.android") + // file_picker's own jvmTarget = 17 setup is behind the same dead AGP9 guard, so its + // Kotlin compile tasks would otherwise default to the running JDK's target (21), + // conflicting with the javac target (17) set by its `compileOptions` block. + tasks.withType().configureEach { + compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) + } + } + } +} + tasks.register("clean") { delete(rootProject.layout.buildDirectory) }