Skip to content

[CP-stable]Roll forward: "Initialize default-app-flavor" (#169298) - #169623

Merged
auto-submit[bot] merged 3 commits into
flutter:flutter-3.32-candidate.0from
flutteractionsbot:cp-stable-8e8cb9255339b347bb551cc4c4101007fe83d63f
May 29, 2025
Merged

auto-submit[bot] merged 3 commits into
flutter:flutter-3.32-candidate.0from
flutteractionsbot:cp-stable-8e8cb9255339b347bb551cc4c4101007fe83d63f

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented May 28, 2025 •

Copy link
Copy Markdown
Contributor

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:

What is the link to the issue this cherry-pick is addressing?

#169602

Changelog Description:

Explain this cherry pick in one line that is accessible to most Flutter developers. See best practices for examples

Fixes a bug where appFlavor is null when being run with flutter test or being hot-restarted.

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)

Cannot reliably use appFlavor without rebuilding the app from scratch.

Workaround:

Is there a workaround for this issue?

Do not use hot restart, do not use flutter test.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

What are the steps to validate that this fix works?

Automated test coverage.

…er#169602)

Closes flutter#169598 (which explains
the integration test failure).
Closes flutter#169160.
Closes flutter#165803.

This is the only diff from 5d013c7:
```diff
diff --git a/packages/flutter_tools/lib/src/build_system/targets/common.dart b/packages/flutter_tools/lib/src/build_system/targets/common.dart
index 6158321..6773101 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/common.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/common.dart
@@ -308,10 +308,18 @@ class KernelSnapshot extends Target {
     if (flavor == null) {
       return;
     }
-    if (!dartDefines.any((String element) => element.startsWith(kAppFlavor))) {
-      // If the flavor is not already in the dart defines, add it.
-      dartDefines.add('$kAppFlavor=$flavor');
-    }
+
+    // It is possible there is a flavor already in dartDefines, from another
+    // part of the build process, but this should take precedence as it happens
+    // last (xcodebuild execution).
+    //
+    // See flutter#169598.
+
+    // If the flavor is already in the dart defines, remove it.
+    dartDefines.removeWhere((String define) => define.startsWith(kAppFlavor));
+
+    // Then, add it to the end.
+    dartDefines.add('$kAppFlavor=$flavor');
   }
 }
 ```
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label May 28, 2025
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

@matanlurey please fill out the PR description above, afterwards the release team will review this request.

@flutter-dashboard

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 28, 2025
@matanlurey
matanlurey requested a review from eyebrowsoffire May 28, 2025 22:01

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

Approved with 2 changes.

Please add a comment with your plan on when you will update the change log since 3.32 is stable.

Please update your changelog entry to match the formatting expectations in https://github.com/flutter/flutter/blob/master/docs/releases/Hotfix-Documentation-Best-Practices.md

@matanlurey

Copy link
Copy Markdown
Contributor

I'll start a CHANGELOG update now in another PR to avoid re-running every test.

@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label May 29, 2025
@auto-submit
auto-submit Bot merged commit 0a159b3 into flutter:flutter-3.32-candidate.0 May 29, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 30, 2025
@flutteractionsbot
flutteractionsbot deleted the cp-stable-8e8cb9255339b347bb551cc4c4101007fe83d63f branch July 20, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App cp: review Cherry-picks in the review queue tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants