Skip to content

refactor(package_info_plus): change android gradle from groovy to kotlin#3858

Open
mdmahendri wants to merge 1 commit into
fluttercommunity:mainfrom
mdmahendri:refactor/package-info-plus-kotlin-dsl
Open

refactor(package_info_plus): change android gradle from groovy to kotlin#3858
mdmahendri wants to merge 1 commit into
fluttercommunity:mainfrom
mdmahendri:refactor/package-info-plus-kotlin-dsl

Conversation

@mdmahendri
Copy link
Copy Markdown

@mdmahendri mdmahendri commented May 30, 2026

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_plugin

Several 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:

Package Minimum Version Source
device_info_plus 3.38.1 pubspec.yaml
network_info_plus 3.38.1 pubspec.yaml
package_info_plus 3.38.1 pubspec.yaml
share_plus 3.38.1 pubspec.yaml

This 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:

  • lintOptions was deprecated in AGP 7.2. Migrated to the modern lint block.
  • Removed implementation "org.jetbrains.kotlin:kotlin-stdlib...". Since Kotlin 1.4, this dependency is added by default by the compiler (reference).
  • Removed the explicit sourceSets block adding src/main/kotlin. Starting with AGP 7, Kotlin source directories are recognized automatically.
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
    
  • Fixed an unresolved dependency conflict between integration_test and the example app test runner, resolving the following Android Studio warning:
    Unresolved dependencies
    Cannot find a version of 'androidx.test:runner' that satisfies the version constraints:
       Dependency path 'android:app:unspecified' --> 'androidx.test:runner:1.6.2'
       Constraint path 'android:app:unspecified' --> 'androidx.test:runner:{strictly 1.2.0}' because of the following reason: version resolved in configuration ':app:debugRuntimeClasspath' by consistent resolution
       Dependency path 'android:app:unspecified' --> 'androidx.test.espresso:espresso-core:3.6.1' (runtime) --> 'androidx.test:runner:1.6.1'
    
  • Migrated kotlinOptions to compilerOptions: Removed the deprecated 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.).
  • Flutter 3.19 or higher make it completely safe to remove the legacy lines of def flutterVersionCode and just point directly to flutter.versionCode and flutter.versionName

Related Issues

  • None reported; this is a proactive codebase health improvement. This same change has already been implemented by the Flutter team in the official flutter/packages repository.
  • This updates the codebase structure, ensuring smoother maintenance and preparing the plugins for a seamless migration to AGP 9 when required by future Flutter releases.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing. No new issues from what I see beside the issues already reported in my other PR
  • The analyzer (flutter analyze) does not report any problems on my PR. This gradle change already simulated in Android Studio and show no warnings

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • No, this is not a breaking change.

@mdmahendri
Copy link
Copy Markdown
Author

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.

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.

1 participant