-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[CP-stable]fix: Android build fails when minSdk is set below 24 in build.gradle.kts (#173823) #174132
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
[CP-stable]fix: Android build fails when minSdk is set below 24 in build.gradle.kts (#173823) #174132
Conversation
…kts (flutter#173823) (flutter#173825) fix: Android build fails when minSdk is set below 24 in build.gradle.kts (flutter#173823, flutter#173829) <!-- Thanks for filing a pull request! Reviewers are typically assigned within a week of filing a request. To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md --> This PR separates the regex for determining minSdkVersion in groovy or kotlin gradle file when doing Android minSdkVersion migration. Fixes flutter#173823. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **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 [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 --------- Co-authored-by: Reid Baker <1063596+reidbaker@users.noreply.github.com>
@reidbaker please fill out the PR description above, afterwards the release team will review this request. |
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.
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 correctly fixes an issue where Android builds would fail for projects using Kotlin DSL (build.gradle.kts
) with a minSdk
version below 24. The changes are well-implemented, distinguishing between Groovy and Kotlin Gradle files to apply the correct syntax for minSdkVersion
. The regular expressions for detecting outdated SDK versions have been improved for accuracy. The accompanying tests are thorough, with new test cases for Kotlin DSL and improved existing tests for Groovy, ensuring the migration logic is robust. The changes are clean and follow best practices.
I believe this pr is being hit by #174057 |
…c5b4d3229652e4688a16d5a5dd
FYI @reidbaker the merge is not going work, because the head commit in 3.35 is not built yet. |
I am working on #173665, which should make framework-only CPs significantly (5-10x) faster. |
79bd284
into
flutter:flutter-3.35-candidate.0
This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
Issue Link:
#173823
Changelog Description:
Explain this cherry pick in one line that is accessible to most Flutter developers. See best practices for examples
On Android builds that do not use flutter.minSdkVersion and do use a value lower than 24 in a kotlin build file, correct flutters auto migration to update value with kotlin syntax. #173825
Impact Description:
What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch)
3.35 bumped the min android api level to api 24. We have an auto migrator to handle if users did not use flutter.minSdkVersion and did set an integer to auto update. The auto update logic produces a syntax error in kotlin build files but the matcher matches kotlin build files. CP is a good idea because 3.35 users are the most likley to be impacted.
Workaround:
Is there a workaround for this issue?
Manually edit build.gradle.kts
Risk:
What is the risk level of this cherry-pick?
Test Coverage:
Are you confident that your fix is well-tested by automated tests?
Validation Steps:
What are the steps to validate that this fix works?
Take flutter build that uses minsdk 22, update to flutter 3.35 and run flutter build apk.