Repository navigation
Migrate to Flutter's built-in Kotlin (Flutter 3.44+) - #139
Merged
Merged
Conversation
Flutter 3.44 requires plugin authors to use Flutter's built-in Kotlin
instead of applying the Kotlin Gradle Plugin themselves.
- android/build.gradle: drop `apply plugin: 'kotlin-android'` and the KGP
classpath, replace the `kotlinOptions` block with `kotlin { compilerOptions }`
(JVM_1_8 to preserve the Java 8 target), and bump KGP to 2.2.20
- example app: migrate to built-in Kotlin (builtInKotlin/newDsl = true,
remove kotlin-android, use the kotlin { compilerOptions } DSL)
- require Flutter 3.44 / Dart 3.12 and bump to 5.0.0 (breaking)
Fixes #137
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Migrates the plugin and example Android project to Flutter 3.44+ “built-in Kotlin” support, removing direct Kotlin Gradle Plugin application and aligning Kotlin/JVM compiler configuration with the new recommended DSL. This is released as a breaking change by bumping the package to 5.0.0 and raising the minimum Flutter/Dart SDK constraints.
Changes:
- Raise minimum SDK constraints and bump package version to 5.0.0 (Flutter >= 3.44.0, Dart ^3.12.0).
- Android migration: stop applying/declaring the Kotlin Gradle Plugin in the plugin module; switch from
kotlinOptionstokotlin { compilerOptions }. - Example app migration: enable
android.builtInKotlin+android.newDsl, removekotlin-androidfrom the app module, and bump Kotlin plugin declaration to 2.2.20.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pubspec.yaml | Bumps major version and raises minimum Flutter/Dart constraints for the breaking migration. |
| CHANGELOG.md | Documents the 5.0.0 breaking change and Kotlin migration details. |
| android/build.gradle | Removes KGP classpath/application and switches Kotlin JVM target configuration to compilerOptions. |
| example/android/app/build.gradle | Removes kotlin-android plugin and moves JVM target to kotlin { compilerOptions }. |
| example/android/gradle.properties | Enables android.builtInKotlin=true and android.newDsl=true to prevent Flutter from rewriting opt-out flags. |
| example/android/settings.gradle | Bumps org.jetbrains.kotlin.android declaration to 2.2.20 for the example project. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #137
Flutter 3.44 requires plugin authors to rely on Flutter's built-in Kotlin instead of applying the Kotlin Gradle Plugin themselves (migration guide). This migrates both the plugin and the example app.
Plugin (
android/build.gradle)apply plugin: 'kotlin-android'and theorg.jetbrains.kotlin:kotlin-gradle-pluginclasspath — Kotlin is now provided by Flutter's built-in Kotlin support.kotlinOptions { jvmTarget = '1.8' }block withkotlin { compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 } }(keptJVM_1_8to preserve the plugin's existing Java 8 target).2.2.10 → 2.2.20(the minimum Flutter now recommends).Example app (
example/android/)kotlin-androidfrom the app'splugins {}block, droppedkotlinOptions, and switched to thekotlin { compilerOptions }DSL.android.builtInKotlin=trueandandroid.newDsl=trueingradle.propertiessoflutter buildno longer keeps re-writing the=falseopt-out flags.settings.gradleto2.2.20.Version
5.0.0;pubspec.yamlnow requiresflutter: ">=3.44.0"/sdk: ^3.12.0.Note:
org.jetbrains.kotlin.androidkept in examplesettings.gradleThe for-app-developers guide suggests removing that plugin declaration entirely, but I intentionally kept it (bumped to
2.2.20). On AGP 8.13 (what the example uses), built-in Kotlin still sources the Kotlin compiler version from that declaration. Removing it makes the compiler fall back to2.0.0, which is incompatible with the2.2.20stdlib and fails the build withModule was compiled with an incompatible version of Kotlin. The guide's "remove it" step only applies once the project is on AGP 9 with bundled Kotlin.Verification
Verified end-to-end against Flutter 3.45.0 / Dart 3.12.1 / Java 21 / AGP 8.13:
flutter build apk --debugon the example → builds successfully.flutter buildno longer re-addsbuiltInKotlin=false/newDsl=false.builtInKotlinbothtrueandfalse).Remaining (out of scope, pre-existing): Flutter warns that Gradle
8.13.0will soon be unsupported (wants ≥8.14.0) — a wrapper-version bump unrelated to this change.🤖 Generated with Claude Code