Skip to content

feat: migrate to built-in Kotlin for AGP 9+ compatibility - #46

Open
ErnestoNCarrea wants to merge 2 commits into
Tkko:mainfrom
ErnestoNCarrea:feat/built-in-kotlin-agp9
Open

ErnestoNCarrea wants to merge 2 commits into
Tkko:mainfrom
ErnestoNCarrea:feat/built-in-kotlin-agp9

Conversation

@ErnestoNCarrea

@ErnestoNCarrea ErnestoNCarrea commented Aug 18, 2026 •

Copy link
Copy Markdown

Summary

AGP 9.0 ships built-in Kotlin support, making the standalone kotlin-android plugin (KGP) unnecessary and causing build failures when applied on AGP 9+ (Cannot add extension with name 'kotlin', as there is an extension already registered with that name).

This PR migrates the plugin to support both AGP 8 (KGP) and AGP 9+ (built-in Kotlin) conditionally, following the official Flutter migration guide for plugin authors.

Changes

File Change
android/build.gradle KGP applied only when agpMajor < 9; kotlinOptions → kotlin { compilerOptions {} }
example/android/app/build.gradle Removed kotlin-android plugin; kotlinOptions → kotlin { compilerOptions {} }
example/android/settings.gradle Removed org.jetbrains.kotlin.android plugin declaration
pubspec.yaml Bumped version 3.2.0 → 3.3.0
CHANGELOG.md Added 3.3.0 entry

Backward compatibility

  • On AGP < 9: KGP is applied as before (no behavior change)
  • On AGP 9+: built-in Kotlin is used, KGP is skipped
  • No minimum Flutter SDK change — the plugin still works with Flutter >= 2.5.0

Fixes #45

AGP 9.0 ships built-in Kotlin support, making the standalone
kotlin-android plugin (KGP) unnecessary and causing build failures
when applied. This PR migrates the plugin to support both AGP 8
(KGP) and AGP 9+ (built-in Kotlin) conditionally.

Changes:
- android/build.gradle: KGP applied only when AGP < 9
- android/build.gradle: kotlinOptions replaced with kotlin.compilerOptions
- example/android/app/build.gradle: removed kotlin-android plugin
- example/android/app/build.gradle: kotlinOptions replaced with kotlin.compilerOptions
- example/android/settings.gradle: removed kotlin-android plugin declaration

Follows the official Flutter migration guide:
https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors

Fixes Tkko#45
@ErnestoNCarrea
ErnestoNCarrea requested a review from Tkko as a code owner August 18, 2026 22:01
- Honor android.builtInKotlin=false opt-out, not just AGP major version
  (Flutter's migrator writes that flag by default)
- Move kotlinOptions inside the KGP guard: the DSL doesn't exist under
  built-in Kotlin, and jvmTarget already follows compileOptions there
- Register src/main/kotlin via the kotlin source set: built-in Kotlin
  doesn't compile .kt files added to the java source set

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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

1 participant