@@ -16,6 +16,43 @@ subprojects {
1616 project.evaluationDependsOn(" :app" )
1717}
1818
19+ // home_widget 0.9.2 skips applying the Kotlin Gradle Plugin when AGP >= 9, assuming the
20+ // project uses AGP's built-in Kotlin. We keep android.builtInKotlin=false (the app and all
21+ // other plugins still apply KGP), so home_widget's Kotlin sources would never compile,
22+ // producing "cannot find symbol HomeWidgetPlugin" at javac time. Apply KGP to it ourselves,
23+ // right after its android library plugin is applied so ordering is correct.
24+ subprojects {
25+ if (name == " home_widget" ) {
26+ pluginManager.withPlugin(" com.android.library" ) {
27+ pluginManager.apply (" org.jetbrains.kotlin.android" )
28+ }
29+ // home_widget's own `jvmTarget = "1.8"` is also gated behind the AGP < 9 check, so
30+ // Kotlin defaults to a target that doesn't match its Java tasks (compiled at 1.8).
31+ // Align Kotlin to 1.8 to avoid "Inconsistent JVM Target Compatibility".
32+ tasks.withType< org.jetbrains.kotlin.gradle.tasks.KotlinCompile > ().configureEach {
33+ compilerOptions {
34+ jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget .JVM_1_8 )
35+ }
36+ }
37+ }
38+ }
39+
40+ // Some plugins declare a compileSdk lower than what their transitive dependencies require.
41+ // gradle.afterProject fires after each project finishes its own configuration, so it
42+ // runs after the module has set its compileSdk and we can safely override it.
43+ gradle.afterProject {
44+ extensions.findByType(com.android.build.gradle.LibraryExtension ::class .java)?.apply {
45+ val minRequired = when (project.name) {
46+ // glance-appwidget:1.3.0-alpha01 and remote-creation-android:1.0.0-alpha11
47+ // both require compileSdk 37+, but home_widget declares only 36.
48+ " home_widget" -> 37
49+ // sound_effect 0.1.3 declares compileSdk 35 but flutter_plugin_android_lifecycle requires 36+.
50+ else -> 36
51+ }
52+ if ((compileSdk ? : 0 ) < minRequired) compileSdk = minRequired
53+ }
54+ }
55+
1956tasks.register<Delete >(" clean" ) {
2057 delete(rootProject.layout.buildDirectory)
2158}
0 commit comments