refactor(package_info_plus): change android gradle from groovy to kotlin#3858
Conversation
|
After cleaning up the Gradle files from outdated or legacy code, I think we can move forward with the steps to support AGP 9. The migration guide here https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin/for-plugin-authors#supporting-flutter-versions-earlier-than-3-44 has a section on how to keep the minimum Flutter version as it is. We don't even need to change the hardcoded AGP versions in the packages. I will check the 5 remaining packages and clean up their Gradle files next, without changing them to Kotlin DSL. |
9b0d197 to
ace71bb
Compare
ace71bb to
78039cd
Compare
vbuberen
left a comment
There was a problem hiding this comment.
Since the change of dependencies version happened in the example app, it is Ok here, but for future don't mix changes that are not related to the title of the PR.
|
Right. We can document that in a separate issue since it's just a warning and not blocking the build process. I also noticed that the Windows integration test is failing in CI, but I can't reproduce it locally. The integration tests pass fine on my machine. |
Description
Background
Starting from Flutter 3.29, new projects use Kotlin DSL by default instead of Groovy for Android build configurations. This can be easily verified by creating a new plugin template:
flutter create --org com.example --template=plugin --platforms=android,ios,web my_pluginSeveral plugins in this repository specify a minimum Flutter SDK higher than 3.29 (see table below). They should follow the latest Android tooling standards and move away from Groovy:
device_info_pluspubspec.yamlnetwork_info_pluspubspec.yamlpackage_info_pluspubspec.yamlshare_pluspubspec.yamlThis change DOES NOT bump the Android Gradle Plugin (AGP) version; the project still targets AGP 8. However, it removes deprecated notations and irrelevant legacy code to align fully with modern AGP expectations.
Additional Gradle Refactors Applied
Alongside the core migration documented in the Gradle Migration Guide and similar change done by the Flutter team in
flutter/packages, the following cleanups were made:lintOptionswas deprecated in AGP 7.2. Migrated to the modernlintblock.implementation "org.jetbrains.kotlin:kotlin-stdlib...". Since Kotlin 1.4, this dependency is added by default by the compiler (reference).sourceSetsblock addingsrc/main/kotlin. Starting with AGP 7, Kotlin source directories are recognized automatically.sourceSets { main.java.srcDirs += 'src/main/kotlin' }kotlinOptions { jvmTarget = 17 }block highlighted by Android Studio('var jvmTarget: String' is deprecated. Please migrate to the compilerOptions DSL. More details are here: https://kotl.in/u1r8ln.).def flutterVersionCodeand just point directly toflutter.versionCodeandflutter.versionName. Please refer to StackOverflow answer and relevant PRRelated Issues
flutter/packagesrepository.Checklist
CHANGELOG.mdnor the plugin version inpubspec.yamlfiles.flutter analyze) does not report any problems on my PR. This gradle change already simulated in Android Studio and show no warningsBreaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?