Skip to content

[CP-stable][tool] Don't require a Flutter compile task when staging jniLibs - #189075

Merged
auto-submit[bot] merged 1 commit into
flutter:flutter-3.44-candidate.0from
flutteractionsbot:cp-stable-ca9f874f5284de7731d808e111ceae87618639d9
Jul 8, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:flutter-3.44-candidate.0from
flutteractionsbot:cp-stable-ca9f874f5284de7731d808e111ceae87618639d9

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Jul 7, 2026 •

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:

#189049
#188785

Impact Description:

Fixes a compile time crash of android instrumented tests (e.g. assembleDebugAndroidTest, which is relied upon by our packages tests and some ecosystem members such as patrol).

Changelog Description:

Fixes a breakage of android instrumented tests (e.g. assembleDebugAndroidTest, which is relied upon by our packages tests and some ecosystem members such as patrol).

< Replace with changelog description here >
[flutter/188805] Fixes a crash when running android instrumented tests.

Workaround:

No.

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?

Explained in detail in #188785
but in short, go to your flutter/packages checkout, cd to the camera example app and run

flutter build apk --debug --config-only
cd android
./gradlew app:assembleAndroidTest -Pverbose=true

…tter#188805)

The variant-API jniLibs copy task referenced the Flutter compile task by
name via tasks.named(...), which throws when that task is not
registered. It is not registered for builds where
shouldConfigureFlutterTask returns false - e.g. `./gradlew
:app:assembleAndroidTest` after `flutter build apk --config-only`, which
is how flutter/packages' Firebase Test Lab tooling builds - causing
"Could not create task ':app:copyJniLibsflutterBuildDebug'. > Task with
name 'compileFlutterBuildDebug' not found".

Look the compile task up tolerantly with findByName and make the copy
task's intermediateDir input optional, so the task degrades to a no-op
(empty output) when there is no Flutter build for the variant - matching
the forgiving behavior of the previous source-set approach. Adds an
assembleAndroidTest regression test.

Fixes flutter#188785

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@flutteractionsbot
flutteractionsbot requested a review from a team as a code owner July 7, 2026 17:42
@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Jul 7, 2026
@flutteractionsbot
flutteractionsbot requested review from gmackall and removed request for a team July 7, 2026 17:42
@flutteractionsbot

Copy link
Copy Markdown
Contributor Author

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

@flutteractionsbot flutteractionsbot added the cp: review Cherry-picks in the review queue label Jul 7, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 7, 2026
@github-actions github-actions Bot added platform-android Android applications specifically tool Affects the "flutter" command-line tool. See also t: labels. team-android Owned by Android platform team labels Jul 7, 2026
@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.

@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 modifies the Gradle plugin to handle builds where the Flutter compile task is absent, such as assembleAndroidTest, by using tolerant task lookups and marking the intermediate directory as optional. It also adds an integration test for this scenario. The review feedback suggests restricting the task lookup using .withType(FlutterTask::class.java) to maintain Gradle task configuration avoidance.

// Look it up tolerantly (findByName, not named) so this task degrades to a no-op
// with empty output instead of failing to be created when there is no Flutter
// build for the variant. See https://github.com/flutter/flutter/issues/188785.
dependsOn(projectToAddTasksTo.tasks.matching { it.name == compileTaskName })

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.

high

Using tasks.matching { ... } without a type filter forces Gradle to eagerly create and configure every single task in the project to check its name. This defeats task configuration avoidance and can significantly slow down Gradle configuration time. Restricting the query with .withType(FlutterTask::class.java) ensures that only tasks of type FlutterTask are realized.

Suggested change
dependsOn(projectToAddTasksTo.tasks.matching { it.name == compileTaskName })
dependsOn(projectToAddTasksTo.tasks.withType(FlutterTask::class.java).matching { it.name == compileTaskName })

@eyebrowsoffire eyebrowsoffire added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 8, 2026
@auto-submit
auto-submit Bot merged commit a54cf4c into flutter:flutter-3.44-candidate.0 Jul 8, 2026
154 checks passed
@flutteractionsbot
flutteractionsbot deleted the cp-stable-ca9f874f5284de7731d808e111ceae87618639d9 branch July 20, 2026 17:04
Anas-Qasem pushed a commit to Anas-Qasem/flutter that referenced this pull request Aug 11, 2026
…niLibs (flutter#189075)

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:
flutter#189049
flutter#188785

### Impact Description:
Fixes a compile time crash of [android instrumented tests](https://developer.android.com/training/testing/instrumented-tests) (e.g. `assembleDebugAndroidTest`, which is relied upon by our packages tests and some ecosystem members such as patrol).

### Changelog Description:
Fixes a breakage of [android instrumented tests](https://developer.android.com/training/testing/instrumented-tests) (e.g. `assembleDebugAndroidTest`, which is relied upon by our packages tests and some ecosystem members such as patrol).

< Replace with changelog description here >
[flutter/188805] Fixes a crash when running android instrumented tests.

### Workaround:
No.

### 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?

Explained in detail in flutter#188785
but in short, go to your flutter/packages checkout, cd to the camera example app and run
```
flutter build apk --debug --config-only
cd android
./gradlew app:assembleAndroidTest -Pverbose=true
```
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 CICD Run CI/CD cp: review Cherry-picks in the review queue platform-android Android applications specifically 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.

3 participants