Repository: flutter
Issue: [Deferred components] Always stuck when executing `loadLibrary()`
Labels: platform-android,engine,P2,team-android,triaged-android

### Steps to reproduce

Simply following https://docs.flutter.dev/perf/deferred-components on a simple flutter app, and upload the AAB to internal app sharing. (No issue when testing locally using bundletool)

Install the app and open the app normally, and when downloading the dynamic module, it's stuck on infinite loading (while executing `loadLibrary()`). When force closing the app, the dynamic module is listed as downloaded. When reopening the app, the app's stuck on the splash screen and can never be opened again (the `loadLibrary()` is now done in startup because the dynamic module has been downloaded).

Notes:
- Obfusaction active or not has no impact.
- Emulator or real device has no impact.
- I've made some Android apps before with Play Core SDK but never got this kind of issue
- The code is stuck when executing `loadLibrary()`

### Expected results

`loadLibrary()` can be finished bringing the downloaded dynamic module and I can normally use the feature inside the dynamic module.

### Actual results

Stuck on infinite loading when executing `loadLibrary()` regardless the dynamic module has been downloaded or not.

### Code sample

<details open><summary>Content of deferred_components_loading_units.yaml</summary>

```yaml
loading-units:
  - id: 2
    libraries:
      - package:example/navigation/other_entry.dart
      - package:example/navigation/other_module.dart
      - package:example/page/deferred_page.dart
      - package:example/page/deferred_tab.dart
      - package:example/page/deferred_component.dart
```

</details>

<details open><summary>Minimum reproducible example repository</summary>

https://github.com/mrhabibi/deferred_component_example

</details>

### Screenshots or Video

<details open>
<summary>Video demonstration</summary>

https://github.com/flutter/flutter/assets/13618227/a4c68284-0f55-4e3d-acba-ad8264489c95

</details>


### Logs

<details open><summary>Suspicious logs</summary>

```console
2024-03-28 08:37:50.233  4960-4960  ziparchive              com.bukalapak.seller.android         W  Unable to open '/data/app/~~v4oL6MBa3Rdrm2NQkMZjHQ==/com.bukalapak.seller.android-LC5xaYbuBfQ3c8ssY89HwQ==/split_other.dm': No such file or directory
2024-03-28 08:37:50.233  4960-4960  ziparchive              com.bukalapak.seller.android         W  Unable to open '/data/app/~~v4oL6MBa3Rdrm2NQkMZjHQ==/com.bukalapak.seller.android-LC5xaYbuBfQ3c8ssY89HwQ==/split_other.dm': No such file or directory
2024-03-28 08:37:50.235  4960-4960  ziparchive              com.bukalapak.seller.android         W  Unable to open '/data/app/~~v4oL6MBa3Rdrm2NQkMZjHQ==/com.bukalapak.seller.android-LC5xaYbuBfQ3c8ssY89HwQ==/split_other.config.arm64_v8a.dm': No such file or directory
2024-03-28 08:37:50.235  4960-4960  ziparchive              com.bukalapak.seller.android         W  Unable to open '/data/app/~~v4oL6MBa3Rdrm2NQkMZjHQ==/com.bukalapak.seller.android-LC5xaYbuBfQ3c8ssY89HwQ==/split_other.config.arm64_v8a.dm': No such file or directory
2024-03-28 08:37:50.237  4960-4960  .seller.android         com.bukalapak.seller.android         W  Entry not found
2024-03-28 08:37:50.237  4960-4960  ziparchive              com.bukalapak.seller.android         W  Unable to open '/data/app/~~v4oL6MBa3Rdrm2NQkMZjHQ==/com.bukalapak.seller.android-LC5xaYbuBfQ3c8ssY89HwQ==/split_other.config.xxhdpi.dm': No such file or directory
2024-03-28 08:37:50.237  4960-4960  ziparchive              com.bukalapak.seller.android         W  Unable to open '/data/app/~~v4oL6MBa3Rdrm2NQkMZjHQ==/com.bukalapak.seller.android-LC5xaYbuBfQ3c8ssY89HwQ==/split_other.config.xxhdpi.dm': No such file or directory
2024-03-28 08:37:50.237  4960-4960  .seller.android         com.bukalapak.seller.android         W  Entry not found
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.7.12, on macOS 14.4.1 23E224 darwin-arm64, locale en-ID)
    • Flutter version 3.7.12 on channel stable at /Users/mrhabibi/flutter/3.7
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4d9e56e694 (12 months ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/mrhabibi/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/mrhabibi/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • 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.15+0-b2043.56-8887301)

[!] Android Studio (version 2023.1)
    • Android Studio at /Applications/Android Studio 2.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
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] VS Code (version 1.87.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.84.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 123.0.6312.87

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
```

</details>