desktop_drop: restore Android compatibility with AGP < 9 hosts - #495
Conversation
|
With this change I'm getting the error below with Gradle 9.1.0 and Flutter 3.44.8. |
|
Thanks @ekuleshov for testing — that's a regression on the AGP 9 path. You are on AGP 9.1 + Flutter 3.44.8 where built-in Kotlin should provide the Fix: use the Flutter docs' recommended conditional pattern that works on both AGP < 9 and AGP 9+: def agpMajor = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0] as int
if (agpMajor < 9) {
apply plugin: 'kotlin-android'
}
project.extensions.configure(org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension) {
compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 }
}And keep I'll open a follow-up PR with that fix. Could you confirm your |
|
Also my app's jvmTarget is set to JvmTarget.JVM_17 for both java and kotlin code |
|
Thanks for the details @ekuleshov Gradle 9.1 + KGP 2.3.20 + AGP 9.1 is exactly the combo that broke. The issue was the direct Pushed a fix to branch project.extensions.configure(org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension) {
compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 }
}This works whether the extension comes from KGP (AGP <9) or from AGP 9's built-in. I'm working on the fix |
|
@ekuleshov I have just opened #498 |
Problem
desktop_drop 0.8.1 failed at configuration time on every app using AGP < 9 (localsend for example) with:
This affects all apps below Flutter 3.44 — they cannot simply move to AGP 9,
because Flutter itself only supports AGP 9 from 3.44+
(built-in Kotlin migration guide).
For those apps, the 0.8.0 changelog note ("must use AGP 9 or later") is unsatisfiable.
Root cause
android/build.gradlecallskotlin { compilerOptions {} }but never applies KGP:kotlin{}kotlin()not foundThe example app (AGP 9.1) only ever exercised the second row, which is why this went
unnoticed. An alternative fix — raising the plugin's minimum to Flutter 3.44 — would
lock out apps on older stable versions; the conditional keeps every host working.
Fix
Implements the official guide section
"Support Flutter versions earlier than 3.44":
kotlin-androidonly when host AGP major < 91.9.25→2.2.0, since thekotlin.compilerOptions {}DSL requires KGP ≥ 2.0No Dart or Kotlin changes.
Verification
Flutter 3.41.9 · AGP 8.12.1 · Gradle 8.13 against this branch :
run
(
✓ Built app-debug.apk; without the patch this same build fails atconfiguration time, before any compilation starts)
run
Could you tag a
desktop_drop v0.8.2after merge so downstream apps can pick this up? Thanks!