Repository: flutter
Issue: flutter run -d all: couldn't find libflutter.so
Labels: platform-android,tool,P2,c: fatal crash,team-android,triaged-android

## Steps to Reproduce

1. New flutter app with target platforms iOS, MacOS, and Android.
2. `flutter clean && flutter run -d all`

This is a flaky failure, possibly a race. `flutter run` succeeds more often when passing `--verbose`.

**Expected results:**

App running properly on all devices.

**Actual results:**

```
Cleaning Xcode workspace...                                      2,610ms
Cleaning Xcode workspace...                                         3.5s
Deleting build...                                                2,938ms
Deleting .dart_tool...                                             109ms
Deleting .packages...                                                0ms
Deleting Generated.xcconfig...                                       0ms
Deleting flutter_export_environment.sh...                            0ms
Deleting Flutter.podspec...                                          0ms
Deleting ephemeral...                                                2ms
Deleting .flutter-plugins-dependencies...                            0ms
Deleting .flutter-plugins...                                         0ms
Running "flutter pub get" in flutter_app...                        745ms
Using hardware rendering with device sdk gphone x86. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Nexus 5X in debug mode...
Launching lib/main.dart on sdk gphone x86 in debug mode...
Launching lib/main.dart on DartVM Team AAR iPod in debug mode...
Launching lib/main.dart on iPod touch (7th generation) in debug mode...
Launching lib/main.dart on macOS in debug mode...
Found saved certificate choice "Apple Development: Daco Harkes (7CG8QJCAGD)". To clear, use "flutter config".
Signing iOS app for device deployment using developer identity: "Apple Development: Daco Harkes (7CG8QJCAGD)"
Xcode build failed due to concurrent builds, will retry in 2 seconds.
Xcode build failed due to concurrent builds, will retry in 4 seconds.
Running Gradle task 'assembleDebug'...                             64.0s
✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Xcode build failed due to concurrent builds, will retry in 8 seconds.
✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Package install error: Failure [INSTALL_FAILED_INVALID_APK]
Uninstalling old version...
 └─Compiling, linking and signing...                        13.0s
Xcode build done.                                           60.6s
W/FlutterActivityAndFragmentDelegate(19909): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
I/flutter (19909): sumDylib(1, 2) + sumSource(3, 4) + sumStaticLib(5, 6) = 21
I/flutter (19909): Everything is working, auto closing app.
F/crash_dump32(19973): crash_dump.cpp:474] failed to attach to thread 19909, already traced by 0 ()
E/FlutterLoader( 8620): Flutter initialization failed.
E/FlutterLoader( 8620): java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.flutter_app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.flutter_app-1/lib/arm64, /data/app/com.example.flutter_app-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libflutter.so"
E/FlutterLoader( 8620): 	at java.util.concurrent.FutureTask.report(FutureTask.java:94)
E/FlutterLoader( 8620): 	at java.util.concurrent.FutureTask.get(FutureTask.java:164)
E/FlutterLoader( 8620): 	at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete(FlutterLoader.java:202)
E/FlutterLoader( 8620): 	at io.flutter.embedding.engine.FlutterEngine.<init>(FlutterEngine.java:326)
E/FlutterLoader( 8620): 	at io.flutter.embedding.engine.FlutterEngine.<init>(FlutterEngine.java:206)
E/FlutterLoader( 8620): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.setupFlutterEngine(FlutterActivityAndFragmentDelegate.java:252)
E/FlutterLoader( 8620): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:162)
E/FlutterLoader( 8620): 	at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:459)
E/FlutterLoader( 8620): 	at android.app.Activity.performCreate(Activity.java:6237)
E/FlutterLoader( 8620): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
E/FlutterLoader( 8620): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
E/FlutterLoader( 8620): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
E/FlutterLoader( 8620): 	at android.app.ActivityThread.-wrap11(ActivityThread.java)
E/FlutterLoader( 8620): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
E/FlutterLoader( 8620): 	at android.os.Handler.dispatchMessage(Handler.java:102)
E/FlutterLoader( 8620): 	at android.os.Looper.loop(Looper.java:148)
E/FlutterLoader( 8620): 	at android.app.ActivityThread.main(ActivityThread.java:5417)
E/FlutterLoader( 8620): 	at java.lang.reflect.Method.invoke(Native Method)
E/FlutterLoader( 8620): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
E/FlutterLoader( 8620): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/FlutterLoader( 8620): Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.flutter_app-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.flutter_app-1/lib/arm64, /data/app/com.example.flutter_app-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libflutter.so"
E/FlutterLoader( 8620): 	at java.lang.Runtime.loadLibrary(Runtime.java:367)
E/FlutterLoader( 8620): 	at java.lang.System.loadLibrary(System.java:1076)
E/FlutterLoader( 8620): 	at io.flutter.embedding.engine.FlutterJNI.loadLibrary(FlutterJNI.java:117)
E/FlutterLoader( 8620): 	at io.flutter.embedding.engine.loader.FlutterLoader$1.call(FlutterLoader.java:154)
E/FlutterLoader( 8620): 	at io.flutter.embedding.engine.loader.FlutterLoader$1.call(FlutterLoader.java:149)
E/FlutterLoader( 8620): 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/FlutterLoader( 8620): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
E/FlutterLoader( 8620): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
E/FlutterLoader( 8620): 	at java.lang.Thread.run(Thread.java:818)
Installing and launching...                                        18.3s
```

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

`--verbose` repro log: https://gist.githubusercontent.com/dcharkes/389c570c134038c1fb98a6e6fbaead18/raw/06c648348c08ca897670c8541e9a27ad66f29e29/gistfile1.txt

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
Running "flutter pub get" in flutter_app...                        693ms
Analyzing flutter_app...                                                
No issues found! (ran in 2.3s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel master, 2.6.0-6.0.pre.13, on macOS 11.6 20G165 darwin-x64, locale en-GB)
    • Flutter version 2.6.0-6.0.pre.13 at /Users/dacoharkes/flt/engine/flutter
    • Upstream repository https://github.com/flutter/flutter
    • Framework revision bd8ee41f01 (2 weeks ago), 2021-09-08 03:46:06 -0400
    • Engine revision 6a3b04632b
    • Dart version 2.15.0 (build 2.15.0-82.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/dacoharkes/Library/Android/sdk
    • Platform android-30, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
    • Xcode at /Applications/Xcode12.4.app/Contents/Developer
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • 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 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.3)
    • IntelliJ at /Applications/IntelliJ UE (stable).app
    • 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

[✓] VS Code (version 1.60.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.26.0

[✓] Connected device (6 available)
    • Nexus 5X (mobile)                    • 00bbd0419fc34dcd                         • android-arm64  • Android 6.0 (API 23)
    • sdk gphone x86 (mobile)              • emulator-5554                            • android-x86    • Android 11 (API 30) (emulator)
    • DartVM Team AAR iPod (mobile)        • d8b98712b9bd881efa55fc97618ecf02437b4a43 • ios            • iOS 11.4 15F79
    • iPod touch (7th generation) (mobile) • D5AD51EB-2B68-4DCF-B561-9255DBEA3041     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)
    • macOS (desktop)                      • macos                                    • darwin-x64     • macOS 11.6 20G165 darwin-x64
    • Chrome (web)                         • chrome                                   • web-javascript • Google Chrome 94.0.4606.54

```

</details>