Skip to content

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

Merged
vbuberen merged 1 commit into
fluttercommunity:mainfrom
mdmahendri:refactor/package-info-plus-kotlin-dsl
Jun 18, 2026
Merged

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

Conversation

@mdmahendri

@mdmahendri mdmahendri commented May 30, 2026

Copy link
Copy Markdown
Contributor

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.24 or higher make it completely safe to remove the legacy lines of def flutterVersionCode and just point directly to flutter.versionCode and flutter.versionName. Please refer to StackOverflow answer and relevant PR

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
Contributor 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.

@vbuberen vbuberen force-pushed the refactor/package-info-plus-kotlin-dsl branch from ace71bb to 78039cd Compare June 18, 2026 14:52

@vbuberen vbuberen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vbuberen vbuberen merged commit 40bb847 into fluttercommunity:main Jun 18, 2026
16 of 22 checks passed
@mdmahendri

Copy link
Copy Markdown
Contributor Author

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.

D:\...\plus_plugins>fvm flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.44.2, on Microsoft Windows [Version 10.0.26100.8457], locale en-ID)
[✓] Windows Version (Windows 11 or higher, 24H2, 2009)
[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2026 18.7.1)
[✓] Connected device (2 available)
[✓] Network resources

D:\...\plus_plugins>fvm dart run melos exec --scope="package_info_plus_example" -- "flutter test -d windows integration_test/package_info_plus_test.dart"
$ melos exec
  └> flutter test -d windows integration_test/package_info_plus_test.dart
     └> RUNNING (in 1 packages)

------------------------------------------------------------------------------------------------------------------------
package_info_plus_example:
Resolving dependencies...
Downloading packages...
  _fe_analyzer_shared 93.0.0 (104.0.0 available)
  analyzer 10.0.1 (14.0.0 available)
  dart_style 3.1.7 (3.1.9 available)
! device_info_plus 13.1.0 from path ..\..\..\device_info_plus\device_info_plus (overridden in .\pubspec_overrides.yaml)
! device_info_plus_platform_interface 8.1.0 from path ..\..\..\device_info_plus\device_info_plus_platform_interface (overridden in .\pubspec_overrides.yaml)
  flutter_lints 5.0.0 (6.0.0 available)
  lints 5.1.1 (6.1.0 available)
  matcher 0.12.19 (0.12.20 available)
  meta 1.18.0 (1.18.3 available)
  mockito 5.6.4 (5.7.0 available)
  package_config 2.2.0 (3.0.0 available)
! package_info_plus 10.1.0 from path .. (overridden in .\pubspec_overrides.yaml)
! package_info_plus_platform_interface 4.1.0 from path ..\..\package_info_plus_platform_interface (overridden in .\pubspec_overrides.yaml)
  test_api 0.7.11 (0.7.12 available)
  vector_math 2.2.0 (2.4.0 available)
Got dependencies!
11 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
00:00 +0: loading d:/.../plus_plugins/packages/package_info_plus/package_info_plus/example/integration_test/package_info_plus_test.dart
Building Windows application...                                    23.1s
✓ Built build\windows\x64\runner\Debug\package_info_plus_example.exe
00:00 +0: fromPlatform
00:00 +1: example
00:00 +2: (tearDownAll)
00:00 +2: All tests passed!
package_info_plus_example: SUCCESS
------------------------------------------------------------------------------------------------------------------------

$ melos exec
  └> flutter test -d windows integration_test/package_info_plus_test.dart
     └> SUCCESS

@mdmahendri mdmahendri deleted the refactor/package-info-plus-kotlin-dsl branch June 19, 2026 11:01
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