Skip to content

chore(android): support AGP 9 built-in Kotlin#1102

Merged
hiroshihorie merged 2 commits into
mainfrom
hiroshi/agp9-built-in-kotlin
Jun 11, 2026
Merged

chore(android): support AGP 9 built-in Kotlin#1102
hiroshihorie merged 2 commits into
mainfrom
hiroshi/agp9-built-in-kotlin

Conversation

@hiroshihorie

@hiroshihorie hiroshihorie commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

Migrates the Android plugin to AGP 9's built-in Kotlin while keeping older toolchains building (same pattern as flutter-webrtc/flutter-webrtc#2075):

  • Apply the Kotlin Gradle Plugin only when built-in Kotlin is inactive — AGP < 9, or AGP 9 with android.builtInKotlin=false (the configuration Flutter currently ships by default while the ecosystem migrates). When AGP 9's built-in Kotlin is active it registers the kotlin extension itself and rejects KGP, so applying it is skipped.
  • Set the JVM target through the kotlin { compilerOptions {} } DSL when the extension supports it (KGP 1.9+ / AGP 9 built-in Kotlin), falling back to the legacy kotlinOptions DSL for apps still on KGP 1.8.x.
  • Bump the standalone buildscript fallback KGP to 2.1.0 so it is self-consistent.
  • Add a changeset entry for the generated release notes.

Context

AGP 9 uses built-in Kotlin support and rejects Android plugins that still apply KGP directly. This follows the Flutter compatibility migration path instead of raising the minimum supported toolchain.

Verification

  • Example app builds (flutter build apk --debug) on the current stable toolchain (AGP 8.x + modern KGP path).
  • The AGP 9 built-in path mirrors the reviewed and merged flutter-webrtc implementation.

@hiroshihorie hiroshihorie linked an issue Jun 3, 2026 that may be closed by this pull request
@hiroshihorie hiroshihorie changed the title Hiroshi/agp9 built in kotlin chore(android): support AGP 9 built-in Kotlin Jun 3, 2026
@hiroshihorie hiroshihorie marked this pull request as ready for review June 6, 2026 07:46
@hiroshihorie hiroshihorie requested a review from Copilot June 10, 2026 10:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Flutter plugin’s Android Gradle configuration to be compatible with Android Gradle Plugin (AGP) 9’s built-in Kotlin support, avoiding the Kotlin Gradle Plugin application path that AGP 9 rejects, while keeping older AGP setups working.

Changes:

  • Conditionally applies kotlin-android only when the detected AGP major version is < 9.
  • Switches Kotlin JVM target configuration from android.kotlinOptions to the kotlin { compilerOptions { ... } } block.
  • Adds a .changes/ entry for release-note generation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
android/build.gradle Applies Kotlin plugin conditionally based on AGP major version and updates Kotlin compiler options configuration.
.changes/agp9-built-in-kotlin Adds a patch-level “fixed” changeset entry for AGP 9 Kotlin compatibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hiroshihorie hiroshihorie force-pushed the hiroshi/agp9-built-in-kotlin branch from f02d248 to ed2d682 Compare June 11, 2026 17:37
@hiroshihorie hiroshihorie merged commit d031c3f into main Jun 11, 2026
17 checks passed
@hiroshihorie hiroshihorie deleted the hiroshi/agp9-built-in-kotlin branch June 11, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Plugin to Built-in Kotlin

2 participants