-
Notifications
You must be signed in to change notification settings - Fork 29.1k
fix: Android build fails when minSdk is set below 24 in build.gradle.kts (#173823) #173825
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
Conversation
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
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 aims to fix an Android build failure when minSdk
is below 24 by separating the regex for Groovy and Kotlin Gradle files. The approach of using two regexes for space-separated and equals-separated syntax is a good start. However, the migration logic incorrectly applies a Kotlin-specific replacement to Groovy files that use equals syntax, which could break builds. I've provided a critical review comment with a suggested fix to correctly handle both file types based on their extension.
packages/flutter_tools/lib/src/android/migrations/min_sdk_version_migration.dart
Outdated
Show resolved
Hide resolved
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.
Thank you so much for this pr! Can you add a test to
flutter/packages/flutter_tools/test/general.shard/android/android_project_migration_test.dart
Line 286 in da5c047
await migration.migrate(); |
I should have mentioned that the rest of this pr looks good and the tests that are failing all appear to also be in that file. |
hi @reidbaker. I have added some tests to cover the changes, including correcting the old tests. Please help to check. Thank you! |
We need 2 reviews to land @mboetger can you give this a once over and if you are happy add autosubmit? |
@reidbaker Should we cherry-pick this to stable? |
…ld.gradle.kts (#173823) (flutter/flutter#173825)
@stuartmorgan-g yes |
…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>
…ld.gradle.kts (#173823) (flutter/flutter#173825)
…ld.gradle.kts (#173823) (flutter/flutter#173825)
…9862) Manual roll Flutter from e65380a22076 to 960d1078f876 (36 revisions) Manual roll requested by bmparr@google.com flutter/flutter@e65380a...960d107 2025-08-20 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Reapply "Add set semantics enabled API and wire iOS a11y bridge (#161… (#171198)" (flutter/flutter#174153) 2025-08-20 ahmedsameha1@gmail.com Make sure that a Badge doesn't crash in 0x0 environment (flutter/flutter#172065) 2025-08-20 ahmedsameha1@gmail.com Make sure that CalendarDatePicker & YearPicker don't crash in 0x0 environment (flutter/flutter#173408) 2025-08-20 engine-flutter-autoroll@skia.org Roll Packages from 953cae0 to 58c02e0 (2 revisions) (flutter/flutter#174142) 2025-08-20 ahmedsameha1@gmail.com Make sure that a CircleAvatar doesn't crash in 0x0 environment (flutter/flutter#173498) 2025-08-20 engine-flutter-autoroll@skia.org Roll Dart SDK from 0d674ff61e2e to 0d0a0c394381 (1 revision) (flutter/flutter#174126) 2025-08-20 34871572+gmackall@users.noreply.github.com [Android] Fix version code override calculation in FlutterPlugin (flutter/flutter#174081) 2025-08-20 ahmedsameha1@gmail.com Make sure that a BackButton doesn't crash in 0x0 environment (flutter/flutter#172817) 2025-08-20 engine-flutter-autoroll@skia.org Roll Dart SDK from c5f5a32df36c to 0d674ff61e2e (1 revision) (flutter/flutter#174099) 2025-08-20 100504385+AlsoShantanuBorkar@users.noreply.github.com feat: Added FocusNode prop for DropdownMenu Trailing Icon Button (flutter/flutter#172753) 2025-08-20 32538273+ValentinVignal@users.noreply.github.com Make component theme data defaults use `WidgetStateProperty` (flutter/flutter#173893) 2025-08-20 huy@nevercode.io Fix Menu anchor reduce padding on web and desktop (flutter/flutter#172691) 2025-08-20 engine-flutter-autoroll@skia.org Roll Skia from 4b788d0e5e63 to 721e68fe652a (2 revisions) (flutter/flutter#174095) 2025-08-20 bruno.leroux@gmail.com Fix time picker period selector a11y touch targets (flutter/flutter#170060) 2025-08-20 bruno.leroux@gmail.com Fix SegmentedButton focus issue (flutter/flutter#173953) 2025-08-20 engine-flutter-autoroll@skia.org Roll Dart SDK from e936404543f1 to c5f5a32df36c (1 revision) (flutter/flutter#174089) 2025-08-20 engine-flutter-autoroll@skia.org Roll Skia from 953bfc0e2f2a to 4b788d0e5e63 (1 revision) (flutter/flutter#174086) 2025-08-19 engine-flutter-autoroll@skia.org Roll Skia from 07d71ea4d056 to 953bfc0e2f2a (18 revisions) (flutter/flutter#174072) 2025-08-19 engine-flutter-autoroll@skia.org Roll Dart SDK from 9105d946af95 to e936404543f1 (5 revisions) (flutter/flutter#174074) 2025-08-19 victorsanniay@gmail.com NavigationRail correct traversal order (flutter/flutter#173891) 2025-08-19 victorsanniay@gmail.com Update CupertinoSliverNavigationBar.middle (flutter/flutter#173868) 2025-08-19 matt.kosarek@canonical.com Update the AccessibilityPlugin::Announce method to account for the view (flutter/flutter#172669) 2025-08-19 bkonyi@google.com [ Widget Preview ] Report an error if a web device is unavailable (flutter/flutter#174036) 2025-08-19 mdebbar@google.com [web] Fix error in ClickDebouncer when using VoiceOver (flutter/flutter#174046) 2025-08-19 bkonyi@google.com [ Tool ] Add logging to test_adapter_test.dart (flutter/flutter#174073) 2025-08-19 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from n0EnLlotF2wczlOq_... to V1A1J6uXZ62Q10i9u... (flutter/flutter#174059) 2025-08-19 matanlurey@users.noreply.github.com Cleanup legacy `bringup: true` tasks, either removing or enabling (flutter/flutter#173815) 2025-08-19 sokolovskyi.konstantin@gmail.com Add Shift+Enter shortcut example for TextField. (flutter/flutter#167952) 2025-08-19 131267808+SvenGasterstaedt@users.noreply.github.com Check that the windows architecture is 64-bit and not the process architecture (flutter/flutter#174019) 2025-08-19 56561849+Rushikeshbhavsar20@users.noreply.github.com Improve Stack widget error message for bounded constraints (flutter/flutter#173352) 2025-08-19 42980667+srivats22@users.noreply.github.com [VPAT][A11y] AutoComplete dropdown option is missing button role (flutter/flutter#173297) 2025-08-19 simonpham.dn@gmail.com fix: Android build fails when minSdk is set below 24 in build.gradle.kts (#173823) (flutter/flutter#173825) 2025-08-19 47866232+chunhtai@users.noreply.github.com Reapply "Add set semantics enabled API and wire iOS a11y bridge (#161… (flutter/flutter#171198) 2025-08-19 yvesdelcoigne@gmail.com fix: only use library props for libraries (flutter/flutter#172704) 2025-08-19 engine-flutter-autoroll@skia.org Roll Packages from 5c52c55 to 953cae0 (22 revisions) (flutter/flutter#174040) 2025-08-19 matanlurey@users.noreply.github.com Add `open_jdk` to `Linux linux_android_emulator.debug_x64` (flutter/flutter#173989) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose ...
…ild.gradle.kts (#173823) (#174132) This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) 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](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) 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.
…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>
…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>
fix: Android build fails when minSdk is set below 24 in build.gradle.kts (#173823, #173829)
This PR separates the regex for determining minSdkVersion in groovy or kotlin gradle file when doing Android minSdkVersion migration.
Fixes #173823.
Pre-launch Checklist
///
).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. 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.