Skip to content

Fall back to source AndroidManifest.xml if AAPT fails or returns garbage#187197

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
mboetger:resolve-issue-50677
Jun 16, 2026
Merged

Fall back to source AndroidManifest.xml if AAPT fails or returns garbage#187197
auto-submit[bot] merged 5 commits into
flutter:masterfrom
mboetger:resolve-issue-50677

Conversation

@mboetger

@mboetger mboetger commented May 27, 2026

Copy link
Copy Markdown
Contributor
  • Fall back to source AndroidManifest.xml if extracting the manifest from the built APK fails.
  • Harden AndroidApk.fromApk to catch all exceptions during parsing (including RangeError or AssertionError if AAPT returns garbage) to ensure the fallback is triggered instead of crashing the tool.
  • Add unit tests to verify fallback behavior when AAPT fails or returns garbage.

Graceful fail for #50677

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

…eturns garbage

* Fall back to source AndroidManifest.xml if extracting the manifest from the built APK fails.
* Harden `AndroidApk.fromApk` to catch all exceptions during parsing (including `RangeError` or `AssertionError` if AAPT returns garbage) to ensure the fallback is triggered instead of crashing the tool.
* Add unit tests to verify fallback behavior when AAPT fails or returns garbage.

TAG=agy
CONV=0a51190b-cd99-402a-9b47-9311f6d010bf
@mboetger mboetger requested a review from a team as a code owner May 27, 2026 20:24
@mboetger mboetger requested review from camsim99 and removed request for a team May 27, 2026 20:24
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 27, 2026
@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 27, 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 wraps APK manifest parsing in a try-catch block to handle failures gracefully, and implements a fallback to the source AndroidManifest.xml when extracting the manifest from the built APK fails. Corresponding unit tests are added to verify this fallback behavior. The reviewer suggests asserting that the fake process manager has no remaining expectations in the new tests to ensure the commands are executed as expected.

- Add expect(fakeProcessManager, hasNoRemainingExpectations) to both AVD lock error fallback tests inside application_package_test.dart.
- This ensures that the mocked aapt command is actually invoked by the test before triggering the source manifest fallback.

TAG=agy
CONV=d492ea8e-4d8e-443f-b7c7-76f68efb5fc4
@github-actions github-actions Bot removed the CICD Run CI/CD label May 29, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 29, 2026
Comment thread packages/flutter_tools/lib/src/android/application_package.dart
Narrow the try-catch block to only surround the parsing of the manifest data, as suggested in PR feedback.

TAG=agy

CONV=4df5de21-7d8f-4971-accd-0278bf9be5dd
@github-actions github-actions Bot removed the CICD Run CI/CD label Jun 11, 2026
@mboetger mboetger requested a review from camsim99 June 11, 2026 19:58
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 11, 2026

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

LGTM

auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Jun 17, 2026
flutter/flutter@3a0420c...b10d0f1

2026-06-17 mr-peipei@web.de Skip platform-specific plugin registration if no platforms enabled (flutter/flutter#186304)
2026-06-17 engine-flutter-autoroll@skia.org Roll Packages from 8286d39 to 6ce00a8 (1 revision) (flutter/flutter#188109)
2026-06-17 engine-flutter-autoroll@skia.org Roll Skia from 79f93fd5f36e to 5d19002eb73e (1 revision) (flutter/flutter#188108)
2026-06-17 simon@journeyapps.com Import `dart:_js_interop_wasm` in addition to `dart:_wasm` to convert between `JSAny` and `WasmExternRef?` (flutter/flutter#186974)
2026-06-17 engine-flutter-autoroll@skia.org Roll Dart SDK from f811ecae9ca0 to e39bde5b1bfc (2 revisions) (flutter/flutter#188107)
2026-06-17 engine-flutter-autoroll@skia.org Roll Skia from 026f6a6be2b9 to 79f93fd5f36e (1 revision) (flutter/flutter#188105)
2026-06-17 engine-flutter-autoroll@skia.org Roll Dart SDK from 462bf0a1d489 to f811ecae9ca0 (1 revision) (flutter/flutter#188099)
2026-06-17 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from VeLhhlDcod09NR4Hb... to or21OEdGtairm6nl9... (flutter/flutter#188098)
2026-06-17 engine-flutter-autoroll@skia.org Roll Skia from 2ffd155313f5 to 026f6a6be2b9 (10 revisions) (flutter/flutter#188097)
2026-06-17 engine-flutter-autoroll@skia.org Roll Dart SDK from 824b4b48b6d4 to 462bf0a1d489 (1 revision) (flutter/flutter#188093)
2026-06-17 jason-simmons@users.noreply.github.com Manual Dart roll from f6c31f4c3a63 to 824b4b48b6d4 (flutter/flutter#188023)
2026-06-17 awolff@google.com Add a platform view test to android_hardware_smoke_test (flutter/flutter#188069)
2026-06-17 44747303+theprantadutta@users.noreply.github.com [flutter_tools] Format empty app template with latest dart format (flutter/flutter#187443)
2026-06-16 49699333+dependabot[bot]@users.noreply.github.com Bump the all-github-actions group across 1 directory with 3 updates (flutter/flutter#188086)
2026-06-16 engine-flutter-autoroll@skia.org Roll Skia from d7196b0b4939 to 2ffd155313f5 (9 revisions) (flutter/flutter#188081)
2026-06-16 43089218+chika3742@users.noreply.github.com Prevent downgrading `project.pbxproj` when greater version number (flutter/flutter#186250)
2026-06-16 magder@google.com Only allow dependabot to autoupdate GitHub-owned actions (flutter/flutter#187936)
2026-06-16 matt.boetger@gmail.com Fall back to source AndroidManifest.xml if AAPT fails or returns garbage (flutter/flutter#187197)
2026-06-16 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#187769)
2026-06-16 jason-simmons@users.noreply.github.com [Impeller] Move queue submission into a callback that is invoked by FenceWaiterVK::AddFence only if it can accept the fence (flutter/flutter#187761)
2026-06-16 jhy03261997@gmail.com Reland [a11y] Map some framework semantics roles to android classes.  (flutter/flutter#188037)
2026-06-16 1961493+harryterkelsen@users.noreply.github.com refactor(web): Unify Image on Skwasm and CanvasKit (flutter/flutter#187873)
2026-06-16 30870216+gaaclarke@users.noreply.github.com Adds arm64 variant of impeller devicelab tests for windows. (flutter/flutter#188053)

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

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Jun 18, 2026
…age (flutter#187197)

* Fall back to source AndroidManifest.xml if extracting the manifest
from the built APK fails.
* Harden `AndroidApk.fromApk` to catch all exceptions during parsing
(including `RangeError` or `AssertionError` if AAPT returns garbage) to
ensure the fallback is triggered instead of crashing the tool.
* Add unit tests to verify fallback behavior when AAPT fails or returns
garbage.

Graceful fail for flutter#50677 

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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.
@mboetger mboetger added the l:backlog LLM created PR addressing a backlog issue. label Jun 18, 2026
via-guy pushed a commit to via-guy/flutter that referenced this pull request Jun 26, 2026
…age (flutter#187197)

* Fall back to source AndroidManifest.xml if extracting the manifest
from the built APK fails.
* Harden `AndroidApk.fromApk` to catch all exceptions during parsing
(including `RangeError` or `AssertionError` if AAPT returns garbage) to
ensure the fallback is triggered instead of crashing the tool.
* Add unit tests to verify fallback behavior when AAPT fails or returns
garbage.

Graceful fail for flutter#50677 

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [X] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD l:backlog LLM created PR addressing a backlog issue. 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