Skip to content

Update AndroidX check to use regex - #188651

Closed
Julienraptor01 wants to merge 1 commit into
flutter:masterfrom
Julienraptor01:patch-1
Closed

Julienraptor01 wants to merge 1 commit into
flutter:masterfrom
Julienraptor01:patch-1

Conversation

@Julienraptor01

@Julienraptor01 Julienraptor01 commented Jun 26, 2026 •

Copy link
Copy Markdown

This check is currently broken as gradle.properties can by example have

android.useAndroidX = true

This has been infuriating me for a while as i hate seeing warnings when there's no reason for

Pre-launch Checklist

@Julienraptor01
Julienraptor01 requested a review from a team as a code owner June 26, 2026 21:44
@Julienraptor01
Julienraptor01 requested review from jesswrd and removed request for a team June 26, 2026 21:44
@flutter-dashboard

Copy link
Copy Markdown

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.

@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 26, 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 updates the isAppUsingAndroidX function in gradle.dart to use a regular expression instead of a substring check when verifying if AndroidX is enabled in gradle.properties. Feedback on this change points out that the proposed regular expression can match commented-out lines, and suggests anchoring the pattern to the start of the line with multi-line matching enabled to avoid false positives.

return false;
}
return properties.readAsStringSync().contains('android.useAndroidX=true');
return RegExp(r'android\.useAndroidX\s*=\s*true').hasMatch(properties.readAsStringSync());

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 regular expression android\.useAndroidX\s*=\s*true can incorrectly match commented-out lines in gradle.properties (for example, # android.useAndroidX=true). To avoid false positives, anchor the pattern to the start of the line using ^ and enable multi-line matching with multiLine: true.

Suggested change
return RegExp(r'android\.useAndroidX\s*=\s*true').hasMatch(properties.readAsStringSync());
return RegExp(r'^\s*android\.useAndroidX\s*=\s*true', multiLine: true).hasMatch(properties.readAsStringSync());

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

the way that it worked before allow for the same exact issue and fixing it is beyond the point of this overly simple PR

@jesswrd jesswrd added the CICD Run CI/CD label Jun 29, 2026

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

To prove the regex works as intended, can you add unit tests here?

@reidbaker
reidbaker requested a review from jesswrd July 14, 2026 21:09
@jesswrd

jesswrd commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Closing since it's been idle for 3 weeks. Also this PR: #188372 addresses the same issue and has unit tests.

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

Labels

CICD Run CI/CD 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.

2 participants