Skip to content

Provide suggested versions in all Gradle compatibility error messages - #188522

Closed
mboetger wants to merge 32 commits into
flutter:masterfrom
mboetger:triage-issue-167931
Closed

mboetger wants to merge 32 commits into
flutter:masterfrom
mboetger:triage-issue-167931

Conversation

@mboetger

Copy link
Copy Markdown
Contributor
  • Refactored KGP/Gradle and AGP/KGP compatibility checks in gradle_utils.dart into declarative constant lists.
  • Implemented bidirectional suggestion helper functions to find compatible ranges for Java, Gradle, AGP, and KGP.
  • Updated project.dart validation to output clear version suggestions for all compatibility violations.
  • Refactored warning accumulation to prevent descriptions from being overwritten.
  • Added comprehensive unit and integration tests covering the compatibility suggestions.

Fixes: #167931

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • 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.

…all Gradle compatibility error messages

- Refactored KGP/Gradle and AGP/KGP compatibility checks in gradle_utils.dart into declarative constant lists.
- Implemented bidirectional suggestion helper functions to find compatible ranges for Java, Gradle, AGP, and KGP.
- Updated project.dart validation to output clear version suggestions for all compatibility violations.
- Refactored warning accumulation to prevent descriptions from being overwritten.
- Added comprehensive unit and integration tests covering the compatibility suggestions.
@mboetger
mboetger requested a review from a team as a code owner June 24, 2026 20:18
@mboetger
mboetger requested review from gmackall and removed request for a team June 24, 2026 20:18
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 24, 2026
@mboetger
mboetger requested a review from reidbaker June 24, 2026 20:18
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-android Owned by Android platform team labels Jun 24, 2026
@mboetger mboetger added the l:backlog LLM created PR addressing a backlog issue. label Jun 24, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Kotlin Gradle Plugin (KGP), Gradle, and Android Gradle Plugin (AGP) compatibility validation logic in gradle_utils.dart by replacing hardcoded conditional blocks with structured data classes and lists. It also updates project.dart to provide detailed version range suggestions in error messages when incompatibilities are detected, and introduces new unit tests to verify these suggestions. The reviewer feedback suggests utilizing the existing oldestDocumentedKgpCompatabilityVersion constant instead of hardcoding a version string, and simplifying the test setup by removing unused template and package configuration code.

@reidbaker
reidbaker self-requested a review July 14, 2026 21:12
reidbaker
reidbaker previously approved these changes Jul 20, 2026
@reidbaker

reidbaker commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

@mboetger there is one last thing I would like you to do. This code duplicates the intent of the work in https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/src/main/kotlin/DependencyVersionChecker.kt

Can you take a pass as figuring out if we can have one source of truth for logic? If that is not possible because of the different languages can you try to make one source of data truth that is read by both pieces of code? Finally if that is not a good solution can you add a test that makes sure the values do not get out of sync?

@reidbaker
reidbaker self-requested a review July 20, 2026 17:16
@github-actions github-actions Bot added the platform-android Android applications specifically label Jul 20, 2026

@reidbaker reidbaker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This code update appears to be an ai generated response to my last comment with no human pass before re-requesting review. @mboetger please review the code on your own before requesting another review from me on this pr. My gut is if you had had reviewed this pr coming from someone else you would have found many of the same suggestions I gave. I ended up stopping part way through the review.

@mboetger

Copy link
Copy Markdown
Contributor Author

I am concerned about the amount of scope creep occurring due the 'single source of truth'. The more I dig into the failing tests I feel like having a runtime dependency on a JSON file is not the correct way of going as it's breaking a lot of the assumptions of some of those tests relying on the flutter root for the JSON file. I think manual step of generating Kotlin and Dart code from single source of truth would alleviate this concern - and some consideration needs to be taken even with that decision. As such, I'm closing this PR.

@mboetger mboetger closed this Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD l:backlog LLM created PR addressing a backlog issue. 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.

Make flutter analyze --suggestion provide suggested versions in all error messages

3 participants