Migrate to built in kotlin for flutter 3.44#49
Conversation
There was a problem hiding this comment.
Code Review
This pull request migrates the project to built-in Kotlin support, updates Android build configurations to target SDK 34, and refines Windows CMake scripts. Feedback highlights critical issues: the kotlin-android plugin and its classpath dependency were incorrectly removed from the plugin's build.gradle, which will break the build. Additionally, the pubspec.yaml files contain non-existent Dart and Flutter versions, and the gradle.properties flags for built-in Kotlin are currently disabled. Upgrading the outdated Android Gradle Plugin is also recommended.
|
|
||
| apply plugin: 'com.android.library' | ||
| apply plugin: 'kotlin-android' | ||
|
|
There was a problem hiding this comment.
For a Flutter plugin containing Kotlin source code, the kotlin-android plugin must still be applied in the plugin's build.gradle file. While the "built-in Kotlin" migration simplifies configuration for the main application, plugin modules still require the Kotlin plugin to compile their source files. Removing this will result in the Kotlin code in src/main/kotlin being ignored during the build.
apply plugin: 'kotlin-android'
| sdk: ^3.12.0 | ||
| flutter: ">=3.44.0" |
There was a problem hiding this comment.
The environment constraints sdk: ^3.12.0 and flutter: ">=3.44.0" appear to be incorrect as these versions have not been released (current stable versions are Dart 3.5 and Flutter 3.24). These settings will prevent the package from being resolved by users. If you intended to target the versions that introduced built-in Kotlin support, you likely meant sdk: ^3.5.0 and flutter: ">=3.24.0".
sdk: ^3.5.0
flutter: ">=3.24.0"| sdk: ^3.12.0 | ||
| flutter: ">=3.44.0" |
There was a problem hiding this comment.
The SDK and Flutter constraints specified here (sdk: ^3.12.0 and flutter: ">=3.44.0") refer to versions that do not yet exist in the stable channel. This will make the plugin unusable for all current Flutter users. Please verify and correct these versions to match the intended target (likely Flutter 3.24.0 and its corresponding Dart SDK).
sdk: ^3.5.0
flutter: ">=3.24.0"| dependencies { | ||
| classpath 'com.android.tools.build:gradle:4.1.0' | ||
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
| } |
There was a problem hiding this comment.
The Kotlin Gradle plugin was removed from the buildscript classpath, but the kotlin configuration block at the end of this file (line 40) relies on classes provided by this plugin (specifically org.jetbrains.kotlin.gradle.dsl.JvmTarget). This will cause a build failure during Gradle evaluation. You should retain the Kotlin plugin in the buildscript dependencies.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24"
}
| # This builtInKotlin flag was added automatically by Flutter migrator | ||
| android.builtInKotlin=false | ||
| # This newDsl flag was added automatically by Flutter migrator | ||
| android.newDsl=false |
There was a problem hiding this comment.
The PR title indicates a migration to built-in Kotlin support, but the flags android.builtInKotlin and android.newDsl are set to false. To actually enable the built-in Kotlin feature introduced in Flutter 3.24, these flags must be set to true.
# This builtInKotlin flag was added automatically by Flutter migrator
android.builtInKotlin=true
# This newDsl flag was added automatically by Flutter migrator
android.newDsl=true
| } | ||
|
|
||
| dependencies { | ||
| classpath 'com.android.tools.build:gradle:4.1.0' |
There was a problem hiding this comment.
The Android Gradle Plugin (AGP) version 4.1.0 is significantly outdated and may not be fully compatible with compileSdkVersion 34 or the modern Kotlin DSL features used later in this file. It is recommended to upgrade to a more recent version (e.g., 7.4.2 or 8.x) to ensure stability and compatibility with current Android build tools.
|
I think gemini code assist is showing outdated information. |
This allows the plugin to be consumed by projects using
android/generated by flutter 3.44see: https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin
Includes the fix from #48