Repository: flutter
Issue: [Flutter 3][Deferred Components] Building an appbundle fails
Labels: c: crash,platform-android,tool,dependency: dart,t: gradle,has reproducible steps,P3,found in release: 3.0,found in release: 3.1,team-android,triaged-android

Can't build appbundle with flutter 3. It works without any issue on previous flutter 2.10.5.

It gives me error if I use deferred components and at the same time use even just one of these packages:

```
- video_player: ^2.4.7
- just_audio: ^0.9.28
- google_sign_in: ^5.4.1
- in_app_review: ^2.0.4
- url_launcher: ^6.1.5
```

If alternatively I exclude deferred components or these packages build complete successfully.

This is the complete list of other packages that I use without any issue:

```
  cupertino_icons: ^1.0.2
  flutter_svg: ^1.0.3
  provider: ^6.0.2
  firebase_core: '^1.14.1'
  firebase_auth: ^3.3.14
  firebase_storage: ^10.2.12
  cloud_firestore: ^3.1.12
  cloud_functions: ^3.3.5
  flutter_facebook_auth: ^4.3.0
  font_awesome_flutter: ^10.1.0
  sign_in_with_apple: ^4.1.0
  crypto: ^3.0.1
  in_app_purchase: ^3.0.7
  email_validator: ^2.0.1
  firebase_dynamic_links: ^4.1.3
  flutter_launcher_icons: ^0.10.0
  flutter_inappwebview: ^5.4.3+7
  shared_preferences: ^2.0.13
  carousel_slider: ^4.0.0
  intl: ^0.17.0
  flip_card: ^0.6.0
```

This is the error on `flutter build appbundle`:

<details>
<summary>logs</summary>

```
===== CRASH =====
si_signo=Segmentation fault: 11(11), si_code=1, si_addr=0x1727f5020
version=2.17.6 (stable) (Tue Jul 12 12:54:37 2022 +0200) on "macos_arm"
pid=68563, thread=-1, isolate_group=isolate(0x7ff63380d600), isolate=isolate(0x7ff633813200)
isolate_instructions=0, vm_instructions=0
  pc 0x0000000102d58a8e fp 0x000000030a6cd260 dart::Serializer::RecordDeferredCode(dart::CodePtr)+0x3e
  pc 0x0000000102d68f58 fp 0x000000030a6cd2c0 dart::CodeSerializationCluster::Trace(dart::Serializer*, dart::ObjectPtr)+0x78
  pc 0x0000000102d5aaa1 fp 0x000000030a6cd370 dart::Serializer::Serialize(dart::SerializationRoots*)+0x1a1
  pc 0x0000000102d5e26a fp 0x000000030a6cd5d0 dart::FullSnapshotWriter::WriteProgramSnapshot(dart::ZoneGrowableArray<dart::Object*>*, dart::GrowableArray<dart::LoadingUnitSerializationData*>*)+0xda
  pc 0x0000000102d5e7f7 fp 0x000000030a6cd600 dart::FullSnapshotWriter::WriteFullSnapshot(dart::GrowableArray<dart::LoadingUnitSerializationData*>*)+0x47
  pc 0x0000000103162cb2 fp 0x000000030a6cd900 dart::CreateAppAOTSnapshot(void (*)(void*, unsigned char const*, long), void*, bool, bool, void*, dart::GrowableArray<dart::LoadingUnitSerializationData*>*, dart::LoadingUnitSerializationData*, unsigned int)+0x412
  pc 0x00000001031633ef fp 0x000000030a6cd9e0 dart::Split(void (*)(void*, long, void**, void**), void*, bool, bool, void (*)(void*, unsigned char const*, long), void (*)(void*))+0x39f
  pc 0x0000000103163bf1 fp 0x000000030a6cdab0 Dart_CreateAppAOTSnapshotAsElfs+0x131
  pc 0x0000000102d03642 fp 0x000000030a6cdc50 dart::bin::main(int, char**)+0xf22
  pc 0x000000020391d51e fp 0x000000030a6cdd60 Unknown symbol
-- End of DumpStackTrace

===== CRASH =====
si_signo=Segmentation fault: 11(11), si_code=1, si_addr=0x10ec0c8e0
version=2.17.6 (stable) (Tue Jul 12 12:54:37 2022 +0200) on "macos_x64"
pid=68565, thread=-1, isolate_group=isolate(0x7f95d2008800), isolate=isolate(0x7f95d200c800)
isolate_instructions=0, vm_instructions=0
  pc 0x0000000102a3794e fp 0x0000000309e002b0 dart::Serializer::RecordDeferredCode(dart::CodePtr)+0x3e
  pc 0x0000000102a47496 fp 0x0000000309e00310 dart::CodeSerializationCluster::Trace(dart::Serializer*, dart::ObjectPtr)+0x76
  pc 0x0000000102a397b0 fp 0x0000000309e003c0 dart::Serializer::Serialize(dart::SerializationRoots*)+0x1a0
  pc 0x0000000102a3cfca fp 0x0000000309e00620 dart::FullSnapshotWriter::WriteProgramSnapshot(dart::ZoneGrowableArray<dart::Object*>*, dart::GrowableArray<dart::LoadingUnitSerializationData*>*)+0xda
  pc 0x0000000102a3d557 fp 0x0000000309e00650 dart::FullSnapshotWriter::WriteFullSnapshot(dart::GrowableArray<dart::LoadingUnitSerializationData*>*)+0x47
  pc 0x0000000102e564d2 fp 0x0000000309e00950 dart::CreateAppAOTSnapshot(void (*)(void*, unsigned char const*, long), void*, bool, bool, void*, dart::GrowableArray<dart::LoadingUnitSerializationData*>*, dart::LoadingUnitSerializationData*, unsigned int)+0x412
  pc 0x0000000102e56c0a fp 0x0000000309e00a30 dart::Split(void (*)(void*, long, void**, void**), void*, bool, bool, void (*)(void*, unsigned char const*, long), void (*)(void*))+0x39a
  pc 0x0000000102e573c1 fp 0x0000000309e00b00 Dart_CreateAppAOTSnapshotAsElfs+0x131
  pc 0x00000001029e1072 fp 0x0000000309e00ca0 dart::bin::main(int, char**)+0xf22
  pc 0x000000020337151e fp 0x0000000309e00db0 Unknown symbol
-- End of DumpStackTrace

===== CRASH =====
si_signo=Segmentation fault: 11(11), si_code=1, si_addr=0x10c71c8e0
version=2.17.6 (stable) (Tue Jul 12 12:54:37 2022 +0200) on "macos_simarm64"
pid=68564, thread=-1, isolate_group=isolate(0x7f98ab80dc00), isolate=isolate(0x7f98aa80e800)
isolate_instructions=0, vm_instructions=0
  pc 0x00000001005790ee fp 0x000000030565c2a0 dart::Serializer::RecordDeferredCode(dart::CodePtr)+0x3e
  pc 0x0000000100588c36 fp 0x000000030565c300 dart::CodeSerializationCluster::Trace(dart::Serializer*, dart::ObjectPtr)+0x76
  pc 0x000000010057af50 fp 0x000000030565c3b0 dart::Serializer::Serialize(dart::SerializationRoots*)+0x1a0
  pc 0x000000010057e76a fp 0x000000030565c610 dart::FullSnapshotWriter::WriteProgramSnapshot(dart::ZoneGrowableArray<dart::Object*>*, dart::GrowableArray<dart::LoadingUnitSerializationData*>*)+0xda
  pc 0x000000010057ecf7 fp 0x000000030565c640 dart::FullSnapshotWriter::WriteFullSnapshot(dart::GrowableArray<dart::LoadingUnitSerializationData*>*)+0x47
  pc 0x000000010099bff2 fp 0x000000030565c940 dart::CreateAppAOTSnapshot(void (*)(void*, unsigned char const*, long), void*, bool, bool, void*, dart::GrowableArray<dart::LoadingUnitSerializationData*>*, dart::LoadingUnitSerializationData*, unsigned int)+0x412
  pc 0x000000010099c72a fp 0x000000030565ca20 dart::Split(void (*)(void*, long, void**, void**), void*, bool, bool, void (*)(void*, unsigned char const*, long), void (*)(void*))+0x39a
  pc 0x000000010099cee1 fp 0x000000030565caf0 Dart_CreateAppAOTSnapshotAsElfs+0x131
  pc 0x0000000100522612 fp 0x000000030565cc90 dart::bin::main(int, char**)+0xf22
  pc 0x000000020108e51e fp 0x000000030565cda0 Unknown symbol
-- End of DumpStackTrace
Dart snapshot generator failed with exit code -6
Dart snapshot generator failed with exit code -6
Dart snapshot generator failed with exit code -6


FAILURE: Build failed with an exception.

* Where:
Script '/Users/enricoiurillo/development/sdks/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1156

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/Users/enricoiurillo/development/sdks/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
```
</details>

<details>
<summary>flutter doctor -v</summary>

```
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale it-IT)
    • Flutter version 3.0.5 at /Users/enricoiurillo/development/sdks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (6 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/enricoiurillo/Library/Android/sdk
    • Platform android-32, build-tools 32.0.0
    • ANDROID_HOME = /Users/enricoiurillo/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode 2.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.63.2)
    • Flutter extension version 3.36.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 104.0.5112.101

[✓] HTTP Host Availability
    • All required HTTP hosts are available
```
</details>