fix: use builtInKotlin property to conditionally apply KGP - #500
Conversation
|
this PR seems reverted the migrations. I suppose an agpMajor condition for |
There was a problem hiding this comment.
Pull request overview
Restores Android Kotlin compilation compatibility and prepares desktop_drop 0.8.4.
Changes:
- Applies KGP unconditionally and configures JVM 1.8.
- Bumps the package version and updates the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/desktop_drop/android/build.gradle |
Revises Kotlin plugin configuration. |
packages/desktop_drop/pubspec.yaml |
Bumps version to 0.8.4. |
packages/desktop_drop/CHANGELOG.md |
Documents the Android fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@boyan01 I tried the Tested here: #498 (comment) The KGP warning is non-fatal on Flutter 3.44–3.46 (tracked at flutter/flutter#189770). When Flutter 3.47+ makes it fatal (#498 (comment)), but unconditional apply is the only approach that works on all current AGP + Flutter combinations. Same pattern used by |
|
@boyan01 @ekuleshov
This is more precise than |
| // Apply KGP only when AGP does not provide built-in Kotlin. | ||
| // builtInKotlin=true -> AGP 9+ with Flutter 3.47+ provides Kotlin built-in, skip KGP | ||
| // builtInKotlin=false -> AGP 8 or AGP 9+ with Flutter <3.47, must apply KGP explicitly | ||
| def builtInKotlin = project.hasProperty('android.builtInKotlin') && |
There was a problem hiding this comment.
[P1] Treat a missing android.builtInKotlin property as enabled on AGP 9+
This currently maps a missing property to false, but AGP 9 and Flutter 3.47 default built-in Kotlin to enabled unless the property is explicitly set to false. With AGP 9.1 and the property omitted, this branch reaches apply plugin: kotlin-android and fails during project evaluation because AGP 9 rejects KGP while built-in Kotlin is active. I reproduced this using the checked-in Example at this PR SHA: explicit true passes, explicit false passes through the legacy path, and an absent property fails at line 26.
Please include the AGP major version in this calculation and use the same semantics as Flutter: AGP <9 is always false; AGP 9+ is true unless the property is explicitly false.
|
@boyan01 |
|
Thank you for your patience in fixing this. LGTM |
0.8.3 still fails to compile Kotlin on some AGP/Flutter combos; 0.8.4 branches on the android.builtInKotlin property (MixinNetwork/flutter-plugins#500). Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
Problem
desktop_drop0.8.2 and 0.8.3 failed to compile Kotlin on one AGP version or the other:kotlin()not found — no Kotlin extension without KGP appliedbuiltInKotlin=false):kotlin()not found — AGP 9 doesn't register the extension for plugin subprojects;tasks.withType(KotlinCompile)found no tasks to configureEvery conditional approach (if/else on
agpMajor,tasks.withType) broke one side because on Flutter 3.44,builtInKotlin=falsemeans AGP 9 does NOT automatically provide Kotlin for plugins. The plugin must apply KGP itself.Solution
Branch on the
android.builtInKotlinGradle property instead of the AGP version number:builtInKotlin=false→ apply KGP + usekotlinOptions(AGP 8, or AGP 9 with Flutter <3.47)builtInKotlin=true→ skip KGP + usecompilerOptions(AGP 9 with Flutter 3.47+)This is more precise than checking
agpMajorbecause it directly reads whether AGP provides Kotlin built-in, rather than guessing from the version number. It avoids the KGP non-compliance warning on hosts where it's not needed.Changes
android/build.gradle: Readandroid.builtInKotlinproperty. Conditionally applykotlin-androidand use the appropriate DSL (kotlinOptionsvscompilerOptions).Testing
Both AGP paths verified:
builtInKotlinkotlinOptionskotlinOptionsbuiltInKotlin=truecompilerOptions