[CP-beta] [AGP 9] Update AGP Error With Flutter Docs (#185043)#186040
Conversation
AGP is ready to use. Developers should not be running into this error at all due to support that has been added for Built-in Kotlin flutter#184836. But in the event that they do run into this error, they will be guided to the right docs. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this comment.
Code Review
This pull request replaces the general AGP 9 migration warning with specific documentation URLs for built-in Kotlin migration and opting out of the new DSL. It updates the error handlers to use these URLs and simplifies the output messages. Corresponding unit tests were updated to reflect these changes. Feedback identifies a potential test failure due to an extra space in a string expectation and suggests a grammatical fix for an error message.
| contains( | ||
| 'Starting AGP 9+, the default has become built-in Kotlin. This results in a build failure when', | ||
| ), | ||
| contains(' This results in a build failure when applying the kotlin-android plugin'), |
There was a problem hiding this comment.
This test expectation contains a leading space that is no longer present in the actual error message. In the updated gradle_errors.dart, the string 'This results...' starts on a new line in the multi-line block without any preceding space. This mismatch will cause the test to fail.
| contains(' This results in a build failure when applying the kotlin-android plugin'), | |
| contains('This results in a build failure when applying the kotlin-android plugin'), |
There was a problem hiding this comment.
well it doesnt look like this test failed
| \nTo resolve this update flutter or opt out of `android.newDsl`. For instructions on how to opt out, see: https://docs.flutter.dev/release/breaking-changes/migrate-to-agp-9 | ||
| ${globals.logger.terminal.warningMark} Starting AGP 9+, only the new DSL interface will be read. | ||
| This results in a build failure when applying the Flutter Gradle plugin at ${appGradleFile.path}. | ||
| \nTo resolve this update flutter or opt out of `android.newDsl`. |
There was a problem hiding this comment.
The sentence is missing a comma after 'this' and 'Flutter' should be capitalized for consistency with other error messages and proper naming of the framework.
| \nTo resolve this update flutter or opt out of `android.newDsl`. | |
| \nTo resolve this, update Flutter or opt out of `android.newDsl`. |
References
- Optimize for readability. Code is read more often than it is written. (link)
5867146
into
flutter:flutter-3.44-candidate.0
AGP is ready to use. Developers should not be running into this error at all due to support that has been added for Built-in Kotlin #184836. But in the event that they do run into this error, they will be guided to the right docs: https://docs.flutter.dev/release/breaking-changes/migrate-to-built-in-kotlin.
Issue Link:
What is the link to the issue this cherry-pick is addressing?
#186097
Impacted Users: Flutter Android devs who have updated to AGP 9+ and are applying the Kotlin Gradle Plugin. Users only see this error message if they still somehow receive the android provided error message even after we added support for both Built-in Kotlin and KGP.
Impact Description: To communicate AGP is ready to use and to add useful Flutter docs for migration to Built-in Kotlin.
Changelog Description:
flutter/186097: For Flutter apps on AGP 9+ and opted-in to built-in Kotlin without proper migration and the Flutter support for both Built-in Kotlin and KGP fails here, we will provide a Flutter error message.
Workaround: Updating error message so N/A
Risk: Very low risk
Test Coverage: yes confident
Validation Steps: unit tests or trigger the Android provided error (highly unlikely given we added support)