Repository navigation
DID-10137: [FIX-FLUTTER-KGP] Android: support AGP 9 built-in Kotlin (apply KGP only when built-in Kotlin is off) - #35
Conversation
…apply KGP only when built-in Kotlin is off)
|
Codex review ( 💡 Code reviewReviewed commit:
When the checked-in example runs with its configured AGP 8.11.1, removing Verdict: REQUEST CHANGES |
Both Android example builds now fail when the APK has no MainActivity class, which is what a build that skipped Kotlin compilation produces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reply to the Codex review (P1, keep the Kotlin plugin for the AGP 8 example build): declined, with proof added. On AGP 8 the Flutter Gradle Plugin applies the Kotlin Gradle Plugin to the app module itself when built-in Kotlin is off. The example's build script has a top-level So this is a permanent check rather than an argument: 8c47c14 makes both Android example jobs (AGP 8 and AGP 9 built-in Kotlin) fail when the APK has no |
|
Codex review ( 💡 Code reviewReviewed commit:
With the repository's default AGP 8.11.1 configuration, built-in Kotlin is unavailable, but this block no longer applies Verdict: REQUEST CHANGES |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reply to Codex round 2 (same P1 as round 1): declined, now proven by CI on 8c47c14. Run 42346911071: in The plugins block still carried the template comment about applying Flutter's plugin after the Kotlin Gradle Plugin, which read as if Kotlin were missing; the latest commit replaces it with the explanation above. |
|
Codex review ( 💡 Code reviewReviewed commit: No blocking findings for commit Verdict: APPROVE |
Refs #28
Problem
didit_sdkalways applies the Kotlin Gradle Plugin (KGP).android/build.gradle.ktsdeclaresid("kotlin-android")inplugins { }and sets the JVM target throughandroid { kotlinOptions }, which only exists when KGP is applied. AGP 9 compiles Kotlin itself ("built-in Kotlin") and refuses projects that also apply KGP. Flutter 3.47 scans each plugin'splugins { }block for KGP and, on AGP 9, printsWARNING: Your app uses the following plugins that apply Kotlin Gradle Plugin (KGP): didit_sdk, adding that future versions will fail such builds. The generated variant packages carry the same script.Solution
kotlin-androidfromplugins { }. Apply it only when built-in Kotlin is off (AGP below 9, orandroid.builtInKotlin=false), which is the rule Flutter's own Gradle plugin uses. AGP 8 apps and older Flutter versions keep compiling the plugin.kotlin { compilerOptions }, which exists with both KGP and built-in Kotlin. This needs KGP 2.0+, which the native SDK's Kotlin 2.1 metadata already requires.kotlin-test-junit5andjunit-platform-launcherfor the unit tests. KGP used to infer them; built-in Kotlin does not, sokotlin.test.Testdid not resolve.tool/generate_variant_packages.sh. The generator needs no change.kotlin-android, and akotlin { compilerOptions }block.android.builtInKotlin=true, builds the APK, runs the plugin's unit tests, and fails if Flutter's KGP warning namesdidit_sdk. The AGP 8 job is unchanged.Verification
Run locally with Flutter 3.47.9 and JDK 17:
builtInKotlin=falsemain's script on AGP 9didit_sdk(flag off), build fails (flag on), so the new job catches a regressionflutter analyze: no issues.flutter test: 39/39 passed.