Provide suggested versions in all Gradle compatibility error messages by mboetger · Pull Request #188522 · flutter/flutter · GitHub
Skip to content

Provide suggested versions in all Gradle compatibility error messages#188522

Open
mboetger wants to merge 1 commit into
flutter:masterfrom
mboetger:triage-issue-167931
Open

Provide suggested versions in all Gradle compatibility error messages#188522
mboetger wants to merge 1 commit 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.

Comment on lines +1551 to +1557

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.

medium

To adhere to the repository style guide of avoiding duplicating state, consider using the existing oldestDocumentedKgpCompatabilityVersion constant instead of hardcoding '1.6.20'.

Suggested change
KgpGradleCompat(
kgpMin: '1.6.20',
kgpMax: '1.7.0',
gradleMin: '6.1.1',
gradleMax: '7.0.2',
inclusiveMaxKgp: false,
),
KgpGradleCompat(
kgpMin: oldestDocumentedKgpCompatabilityVersion,
kgpMax: '1.7.0',
gradleMin: '6.1.1',
gradleMax: '7.0.2',
inclusiveMaxKgp: false,
),
References
  1. Avoid duplicating state: Keep only one source of truth. (link)

Comment on lines +106 to +145

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.

medium

The compatibility checks being tested do not use or require the Flutter templates or the package config setup for flutter_tools. Removing this block makes the test faster, cleaner, and completely hermetic by avoiding unnecessary host file system reads.

References
  1. Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)

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

1 participant