Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Bump warn and error versions of agp, kotlin and gradle versions in preparation for gradle 9 #171399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

reidbaker
Copy link
Contributor

https://gradle.org/whats-new/gradle-9/ is coming and with it includes some deprecated methods. Some like #171397 can be fixed by annotations and calling new methods. Some like the deprecation of minsdkversion on Variant require bumping the minimum versions to be able to compile code that will work.

b/368604254

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.


@VisibleForTesting internal val errorGradleVersion: Version = Version(7, 0, 2)
@VisibleForTesting internal val errorGradleVersion: Version = Version(8, 0, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

if I may, in order to unlock filePermissions API (to resolve this), this version should be at least 8.3, because filePermission API was introduced there and it's recommended replacement for fileMode.

Another way - is to use some reflection to invoke either API based on gradle version, but this is error-prone and I believe it should not be the preferred way to solve it. And not 100% sure it's possible in this case :)

Copy link
Contributor

@Sameri11 Sameri11 Jul 1, 2025

Choose a reason for hiding this comment

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

Also, about gradle versions – Android studio (at least stable version) is shipped with JDK 21 on board, and flutter prefers to use studio's jdk. The thing here is running gradle on java 21 is officially supported from gradle 8.5, in prior versions there'll be not-so-obvious errors (I remember many questions on SO when android studio with java 21 onboard first released)

Im not sure, but maybe this "strange" relationship should also be somehow reflected in this version range ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I bumped the minimum gradle version to 8.3.
Java version is determined at the machine level in our ci for most suites of tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to clarify - my point about about 8.5 was mainly from user perspective: android studios bundled jdk is most used for flutter (because the majority of developers do not override it in config, at least that's what I saw) and this jdk requires 8.5 because it is first version which supports running on jdk 21.
This might be frustrating for newcomers, but now I think it's mitigated by the fact that fresh projects use more recent version of gradle from project template
Anyway, I think current version here is ok.


@VisibleForTesting internal val errorAGPVersion: AndroidPluginVersion = AndroidPluginVersion(7, 0, 0)
@VisibleForTesting internal val errorAGPVersion: AndroidPluginVersion = AndroidPluginVersion(8, 1, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it'll be better to use 8.1.1 here? Per Compatibility matrix this version is last supported now for Google Play publishing (android api level should be at least 34 till August 31 2025 -> api level 34 requires at least AGP 8.1.1).
I'm using the kinda-"flutter should support AGP which is suitable for Google play publishing" here, do not know if it should be this way though. But do not see downsides in this approach :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@reidbaker reidbaker requested a review from matanlurey as a code owner July 2, 2025 14:41
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
Copy link
Member

Choose a reason for hiding this comment

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

Hmm shouldn't this file be gitignored based on the entry above? It is within packages/flutter_tools/gradle/.gitignore and has path starting in gradle?

Also I don't think it should be added, should it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to add it with force. Right now what we develop with is different across engineers based on when they ran the wrapper script. That said this change should be talked about and not part of a min version bump. Will remove.


@VisibleForTesting internal val errorAGPVersion: AndroidPluginVersion = AndroidPluginVersion(7, 0, 0)
@VisibleForTesting internal val errorAGPVersion: AndroidPluginVersion = AndroidPluginVersion(8, 1, 1)
Copy link
Member

Choose a reason for hiding this comment

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

I personally would prefer that we bump our Error(AGP) here to 8.3, the value which we have been warning for. This allows us also to bump our Error(Gradle) version to 8.4, as based on https://developer.android.com/build/releases/past-releases/agp-8-3-0-release-notes that is the minimum required.

In the most technical sense it still breaks our policy, and in the future I think we probably should satisfy at all times Warn(Gradle) >= RequiredGradleFor(Warn(AGP)). But because it is required it isn't a meaningful break of the policy, imo. And every other change falls within the policy.

This is a mild preference though and, I admit, at least partially motivated by being able to say we stayed within our policy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We talked about this out of band. I think that giving users a clear error is prefered to technically following our policy and letting users discover that the versions they need are higher than what we enforce. In the future we agree that the Warn(Gradle) >= RequiredGradleFor(Warn(AGP) that is a good policy to have.

Copy link
Member

@gmackall gmackall left a comment

Choose a reason for hiding this comment

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

Bumping our error Gradle version without a release of warning for that Gradle version is unfortunate, but required for supporting Gradle 9, so LGTM.

At least we have been warning about AGP<8.3 for a while, so implicitly we have sort of been warning for Gradle<8.4 (as AGP 8.3 requires Gradle 8.4 🙂 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-android Android applications specifically team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants