Skip to content

Migrate to built-in Kotlin#49

Open
ubxty wants to merge 1 commit into
cloudacy:mainfrom
ubxty:migrate-to-built-in-kotlin
Open

Migrate to built-in Kotlin#49
ubxty wants to merge 1 commit into
cloudacy:mainfrom
ubxty:migrate-to-built-in-kotlin

Conversation

@ubxty

@ubxty ubxty commented Jun 8, 2026

Copy link
Copy Markdown

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

Background

AGP 9.0 will remove support for plugins that apply the Kotlin Gradle
Plugin. Flutter 3.44+ emits a deprecation warning for any plugin that
still does:

Your app uses the following plugins that apply Kotlin Gradle Plugin (KGP).
Future versions of Flutter will fail to build if your app uses plugins
that apply KGP.

This PR removes the legacy apply plugin: "kotlin-android" line and
the KGP classpath from android/build.gradle, and the same from the
example app's example/android/app/build.gradle.kts.

Changes

  • android/build.gradle: remove KGP classpath + apply plugin: "kotlin-android" + kotlinOptions {} block; add kotlin { compilerOptions { jvmTarget = ... } } block
  • example/android/app/build.gradle.kts: same migration in the example app
  • example/android/gradle.properties: flip android.builtInKotlin=true and android.newDsl=true (Flutter migrator had set them to false)
  • pubspec.yaml: bump version 0.8.0 → 0.9.0; minimum Flutter 3.44.0, Dart 3.12.0 (required by the new kotlin.compilerOptions DSL)
  • CHANGELOG.md: new 0.9.0 entry noting the migration

Validation

flutter build apk --debug in the example app on Flutter 3.44.1:

  • BEFORE: Kotlin Gradle Plugin deprecation warning
  • AFTER: zero warnings, clean build, app-debug.apk produced

The new kotlin { compilerOptions { ... } } block uses the
org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 enum value as
required when applying the kotlin-android plugin is removed.

Note on semver

Bumped to 0.9.0 (minor) because the new minimum Flutter version (3.44)
and Dart SDK (3.12) are breaking for consumers on older toolchains.

Removes the legacy kotlin-android plugin apply and the Kotlin Gradle
Plugin classpath from android/build.gradle, per the official Flutter
migration guide at:
  https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors

Also migrates the example app (example/android/app/build.gradle.kts and
example/android/gradle.properties).

Builds cleanly with flutter build apk --debug in the example app, no
Kotlin Gradle Plugin deprecation warnings.

Bumps minimum Flutter version to 3.44.0 and Dart SDK to 3.12.0 as
required by the new compilerOptions DSL.
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.

2 participants