flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.14k stars 27.47k forks source link

Android: Java.lang.UnsatisfiedLinkError: library "libflutter.so" not found with `--local-engine` #114070

Closed dcharkes closed 2 years ago

dcharkes commented 2 years ago

When trying to run on Android with --local-engine on either device or emulator I get the error java.lang.UnsatisfiedLinkError couldn't find "libflutter.so".

Running without --local-engine works as expected on both device and emulator.

Maybe I'm holding it wrong. Are we supposed to do flutter run on Android with a --local-engine?

Possibly related issues:

Device:

$ flutter run -d Nexus --local-engine=android_debug_unopt --local-engine-src-path=/usr/local/google/home/dacoharkes/flt/engine/src
Running "flutter pub get" in flutter_app...                        752ms
Resolving dependencies...
  async 2.9.0 (2.10.0 available)
  matcher 0.12.12 (0.12.13 available)
Got dependencies!
Launching lib/main.dart on Nexus 5X in debug mode...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Running Gradle task 'assembleDebug'...                             24.6s
✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app-debug.apk...          17.0s
E/FlutterLoader( 6054): Flutter initialization failed.
E/FlutterLoader( 6054): java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.flutter_app-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.flutter_app-2/lib/arm64, /data/app/com.example.flutter_app-2/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libflutter.so"
E/FlutterLoader( 6054):     at java.util.concurrent.FutureTask.report(FutureTask.java:94)
E/FlutterLoader( 6054):     at java.util.concurrent.FutureTask.get(FutureTask.java:164)
E/FlutterLoader( 6054):     at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete(FlutterLoader.java:239)
E/FlutterLoader( 6054):     at io.flutter.embedding.engine.FlutterEngine.<init>(FlutterEngine.java:327)
E/FlutterLoader( 6054):     at io.flutter.embedding.engine.FlutterEngine.<init>(FlutterEngine.java:207)
E/FlutterLoader( 6054):     at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.setupFlutterEngine(FlutterActivityAndFragmentDelegate.java:272)
E/FlutterLoader( 6054):     at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:181)
E/FlutterLoader( 6054):     at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:495)
E/FlutterLoader( 6054):     at android.app.Activity.performCreate(Activity.java:6237)
E/FlutterLoader( 6054):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
E/FlutterLoader( 6054):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
E/FlutterLoader( 6054):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
E/FlutterLoader( 6054):     at android.app.ActivityThread.-wrap11(ActivityThread.java)
E/FlutterLoader( 6054):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
E/FlutterLoader( 6054):     at android.os.Handler.dispatchMessage(Handler.java:102)
E/FlutterLoader( 6054):     at android.os.Looper.loop(Looper.java:148)
E/FlutterLoader( 6054):     at android.app.ActivityThread.main(ActivityThread.java:5417)
E/FlutterLoader( 6054):     at java.lang.reflect.Method.invoke(Native Method)
E/FlutterLoader( 6054):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
E/FlutterLoader( 6054):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/FlutterLoader( 6054): Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.flutter_app-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.flutter_app-2/lib/arm64, /data/app/com.example.flutter_app-2/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libflutter.so"
E/FlutterLoader( 6054):     at java.lang.Runtime.loadLibrary(Runtime.java:367)
E/FlutterLoader( 6054):     at java.lang.System.loadLibrary(System.java:1076)
E/FlutterLoader( 6054):     at io.flutter.embedding.engine.FlutterJNI.loadLibrary(FlutterJNI.java:141)
E/FlutterLoader( 6054):     at io.flutter.embedding.engine.loader.FlutterLoader$1.call(FlutterLoader.java:189)
E/FlutterLoader( 6054):     at io.flutter.embedding.engine.loader.FlutterLoader$1.call(FlutterLoader.java:182)
E/FlutterLoader( 6054):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/FlutterLoader( 6054):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
E/FlutterLoader( 6054):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
E/FlutterLoader( 6054):     at java.lang.Thread.run(Thread.java:818)

Emulator:

$ flutter run -d emu --local-engine=android_debug_unopt --local-engine-src-path=/usr/local/google/home/dacoharkes/flt/engine/src
Running "flutter pub get" in flutter_app...                        728ms
Resolving dependencies...
  async 2.9.0 (2.10.0 available)
  matcher 0.12.12 (0.12.13 available)
Got dependencies!
Using hardware rendering with device Android SDK built for x86. If you notice graphics artifacts, consider enabling
software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Running Gradle task 'assembleDebug'...                             22.9s
✓  Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app-debug.apk...          415ms
E/FlutterLoader(24509): Flutter initialization failed.
E/FlutterLoader(24509): java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
E/FlutterLoader(24509):     at java.util.concurrent.FutureTask.report(FutureTask.java:123)
E/FlutterLoader(24509):     at java.util.concurrent.FutureTask.get(FutureTask.java:193)
E/FlutterLoader(24509):     at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete(FlutterLoader.java:239)
E/FlutterLoader(24509):     at io.flutter.embedding.engine.FlutterEngine.<init>(FlutterEngine.java:327)
E/FlutterLoader(24509):     at io.flutter.embedding.engine.FlutterEngine.<init>(FlutterEngine.java:207)
E/FlutterLoader(24509):     at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.setupFlutterEngine(FlutterActivityAndFragmentDelegate.java:272)
E/FlutterLoader(24509):     at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:181)
E/FlutterLoader(24509):     at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:495)
E/FlutterLoader(24509):     at android.app.Activity.performCreate(Activity.java:7994)
E/FlutterLoader(24509):     at android.app.Activity.performCreate(Activity.java:7978)
E/FlutterLoader(24509):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
E/FlutterLoader(24509):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
E/FlutterLoader(24509):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
E/FlutterLoader(24509):     at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
E/FlutterLoader(24509):     at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/FlutterLoader(24509):     at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/FlutterLoader(24509):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
E/FlutterLoader(24509):     at android.os.Handler.dispatchMessage(Handler.java:106)
E/FlutterLoader(24509):     at android.os.Looper.loop(Looper.java:223)
E/FlutterLoader(24509):     at android.app.ActivityThread.main(ActivityThread.java:7656)
E/FlutterLoader(24509):     at java.lang.reflect.Method.invoke(Native Method)
E/FlutterLoader(24509):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/FlutterLoader(24509):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/FlutterLoader(24509): Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
E/FlutterLoader(24509):     at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
E/FlutterLoader(24509):     at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
E/FlutterLoader(24509):     at java.lang.System.loadLibrary(System.java:1664)
E/FlutterLoader(24509):     at io.flutter.embedding.engine.FlutterJNI.loadLibrary(FlutterJNI.java:141)
E/FlutterLoader(24509):     at io.flutter.embedding.engine.loader.FlutterLoader$1.call(FlutterLoader.java:189)
E/FlutterLoader(24509):     at io.flutter.embedding.engine.loader.FlutterLoader$1.call(FlutterLoader.java:182)
E/FlutterLoader(24509):     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/FlutterLoader(24509):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/FlutterLoader(24509):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/FlutterLoader(24509):     at java.lang.Thread.run(Thread.java:923)
E/AndroidRuntime(24509): FATAL EXCEPTION: main
E/AndroidRuntime(24509): Process: com.example.flutter_app, PID: 24509
E/AndroidRuntime(24509): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.flutter_app/com.example.flutter_app.MainActivity}: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
E/AndroidRuntime(24509):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
E/AndroidRuntime(24509):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
E/AndroidRuntime(24509):    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
E/AndroidRuntime(24509):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(24509):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(24509):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
E/AndroidRuntime(24509):    at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(24509):    at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime(24509):    at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime(24509):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(24509):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime(24509):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/AndroidRuntime(24509): Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
E/AndroidRuntime(24509):    at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete(FlutterLoader.java:345)
E/AndroidRuntime(24509):    at io.flutter.embedding.engine.FlutterEngine.<init>(FlutterEngine.java:327)
E/AndroidRuntime(24509):    at io.flutter.embedding.engine.FlutterEngine.<init>(FlutterEngine.java:207)
E/AndroidRuntime(24509):    at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.setupFlutterEngine(FlutterActivityAndFragmentDelegate.java:272)
E/AndroidRuntime(24509):    at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:181)
E/AndroidRuntime(24509):    at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:495)
E/AndroidRuntime(24509):    at android.app.Activity.performCreate(Activity.java:7994)
E/AndroidRuntime(24509):    at android.app.Activity.performCreate(Activity.java:7978)
E/AndroidRuntime(24509):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
E/AndroidRuntime(24509):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
E/AndroidRuntime(24509):    ... 11 more
E/AndroidRuntime(24509): Caused by: java.util.concurrent.ExecutionException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
E/AndroidRuntime(24509):    at java.util.concurrent.FutureTask.report(FutureTask.java:123)
E/AndroidRuntime(24509):    at java.util.concurrent.FutureTask.get(FutureTask.java:193)
E/AndroidRuntime(24509):    at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete(FlutterLoader.java:239)
E/AndroidRuntime(24509):    ... 20 more
E/AndroidRuntime(24509): Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libflutter.so" not found
E/AndroidRuntime(24509):    at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
E/AndroidRuntime(24509):    at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
E/AndroidRuntime(24509):    at java.lang.System.loadLibrary(System.java:1664)
E/AndroidRuntime(24509):    at io.flutter.embedding.engine.FlutterJNI.loadLibrary(FlutterJNI.java:141)
E/AndroidRuntime(24509):    at io.flutter.embedding.engine.loader.FlutterLoader$1.call(FlutterLoader.java:189)
E/AndroidRuntime(24509):    at io.flutter.embedding.engine.loader.FlutterLoader$1.call(FlutterLoader.java:182)
E/AndroidRuntime(24509):    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime(24509):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(24509):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(24509):    at java.lang.Thread.run(Thread.java:923)

Local engine build:

Devices:

$ flutter devices
4 connected devices:

Nexus 5X (mobile)                  • 127.0.0.1:36981 • android-arm64  • Android 6.0 (API 23)
Android SDK built for x86 (mobile) • emulator-5554   • android-x86    • Android 11 (API 30) (emulator)
Linux (desktop)                    • linux           • linux-x64      • Debian GNU/Linux rodete 5.18.16-1rodete1-amd64
Chrome (web)                       • chrome          • web-javascript • Google Chrome 107.0.5304.68

Flutter version:

$ flutter --version
Flutter 3.5.0-10.0.pre.68 • channel master • https://github.com/flutter/flutter
Framework • revision 49f0061afd (32 hours ago) • 2022-10-24 23:51:24 -0400
Engine • revision b93c654bd1
Tools • Dart 2.19.0 (build 2.19.0-330.0.dev) • DevTools 2.18.0

$ flutter doctor -v
[!] Flutter (Channel master, 3.5.0-10.0.pre.68, on Debian GNU/Linux rodete 5.18.16-1rodete1-amd64, locale en_US.UTF-8)
    • Flutter version 3.5.0-10.0.pre.68 on channel master at /usr/local/google/home/dacoharkes/flt/engine/flutter
    ! Warning: `dart` on your path resolves to
      /usr/local/google/home/dacoharkes/dart-sdk/sdk/out/ReleaseX64/dart-sdk/bin/dart, which is not inside your current
      Flutter SDK checkout at /usr/local/google/home/dacoharkes/flt/engine/flutter. Consider adding
      /usr/local/google/home/dacoharkes/flt/engine/flutter/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter
    • Framework revision 49f0061afd (32 hours ago), 2022-10-24 23:51:24 -0400
    • Engine revision b93c654bd1
    • Dart version 2.19.0 (build 2.19.0-330.0.dev)
    • DevTools version 2.18.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly
      to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /usr/local/google/home/dacoharkes/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /usr/local/google/home/dacoharkes/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Debian clang version 14.0.6-2
    • cmake version 3.24.2
    • ninja version 1.8.2
    • pkg-config version 0.29.2

[✓] Android Studio (version 2020.3)
    • Android Studio at /usr/local/google/home/dacoharkes/android-studio
    • 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.60.2)
    • VS Code at /usr/share/code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (4 available)
    • Nexus 5X (mobile)                  • 127.0.0.1:36981 • android-arm64  • Android 6.0 (API 23)
    • Android SDK built for x86 (mobile) • emulator-5554   • android-x86    • Android 11 (API 30) (emulator)
    • Linux (desktop)                    • linux           • linux-x64      • Debian GNU/Linux rodete
      5.18.16-1rodete1-amd64
    • Chrome (web)                       • chrome          • web-javascript • Google Chrome 107.0.5304.68

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
jason-simmons commented 2 years ago

--local-engine is supported on Android devices and emulators.

Make sure that the CPU target of the local engine build matches the device or emulator. Use the flutter/tools/gn --android-cpu flag to select a target architecture.

If it still isn't working, then try unzipping the APK archive built by flutter run and verifying that it includes the expected libflutter.so binary for an ABI that is compatible with the device.

dcharkes commented 2 years ago

Specifying either a single or all --android-cpus seems to have no effect on the build at all.

Running `flutter/tools/gn --full-dart-sdk --no-prebuilt-dart-sdk --goma --runtime-mode=release --android --android-cpu=arm --android-cpu=arm64 --android-cpu=x64 --android-cpu=x86` in /usr/local/google/home/dacoharkes/flt/engine/src/.
  WARNING at the command-line "--args":1:160: Build argument has no effect.
is_debug=false use_goma=true goma_dir="/usr/local/google/home/dacoharkes/depot_tools/.cipd_bin" flutter_build_web_sdk=false full_dart_sdk=true build_canvaskit=false skia_enable_flutter_defines=true skia_use_dng_sdk=false skia_use_sfntly=false skia_enable_pdf=false skia_use_x11=false skia_use_wuffs=true skia_use_expat=true skia_use_fontconfig=false skia_use_legacy_layer_bounds=true skia_use_icu=true flutter_always_use_skshaper=false is_official_build=true android_full_debug=false is_clang=true skia_gl_standard="gles" use_clang_static_analyzer=false enable_coverage=false enable_lto=true target_os="android" target_cpu="x86" dart_target_arch="x86" flutter_use_fontconfig=false flutter_enable_skshaper=true dart_component_kind="static_library" embedder_for_target=false dart_lib_export_symbols=false flutter_runtime_mode="release" dart_version_git_info=true dart_runtime_mode="release" enable_desktop_embeddings=true bssl_use_clang_integrated_as=true skia_use_gl=true disable_hidden_visibility=false stripped_symbols=true
                                                                                                                                                               ^----
The variable "build_canvaskit" was set as a build argument
but never appeared in a declare_args() block in any buildfile.

To view all possible args, run "gn args --list <out_dir>"

The build continued as if that argument was unspecified.

Generating compile_commands took 41ms
Done. Made 580 targets from 248 files in 3165ms
  Generating GN files in: out/android_release_x86
Command `flutter/tools/gn --full-dart-sdk --no-prebuilt-dart-sdk --goma --runtime-mode=release --android --android-cpu=arm --android-cpu=arm64 --android-cpu=x64 --android-cpu=x86` done.
Running `ninja -C out/android_release/ -j1000` in /usr/local/google/home/dacoharkes/flt/engine/src/.
  ninja: Entering directory `out/android_release/'
  ninja: no work to do.
Command `ninja -C out/android_release/ -j1000` done.
Running `flutter/tools/gn --full-dart-sdk --no-prebuilt-dart-sdk --goma --android --android-cpu=arm --android-cpu=arm64 --android-cpu=x64 --android-cpu=x86` in /usr/local/google/home/dacoharkes/flt/engine/src/.
  WARNING at the command-line "--args":1:160: Build argument has no effect.
is_debug=false use_goma=true goma_dir="/usr/local/google/home/dacoharkes/depot_tools/.cipd_bin" flutter_build_web_sdk=false full_dart_sdk=true build_canvaskit=false skia_enable_flutter_defines=true skia_use_dng_sdk=false skia_use_sfntly=false skia_enable_pdf=false skia_use_x11=false skia_use_wuffs=true skia_use_expat=true skia_use_fontconfig=false skia_use_legacy_layer_bounds=true skia_use_icu=true flutter_always_use_skshaper=false is_official_build=true android_full_debug=false is_clang=true skia_gl_standard="gles" use_clang_static_analyzer=false enable_coverage=false enable_lto=true target_os="android" target_cpu="x86" dart_target_arch="x86" flutter_use_fontconfig=false flutter_enable_skshaper=true dart_component_kind="static_library" embedder_for_target=false dart_lib_export_symbols=false flutter_runtime_mode="debug" dart_version_git_info=true dart_runtime_mode="develop" enable_desktop_embeddings=true bssl_use_clang_integrated_as=true skia_use_gl=true disable_hidden_visibility=false stripped_symbols=true
                                                                                                                                                               ^----
The variable "build_canvaskit" was set as a build argument
but never appeared in a declare_args() block in any buildfile.

To view all possible args, run "gn args --list <out_dir>"

The build continued as if that argument was unspecified.

Generating compile_commands took 42ms
Done. Made 609 targets from 254 files in 3221ms
  Generating GN files in: out/android_debug_x86
Command `flutter/tools/gn --full-dart-sdk --no-prebuilt-dart-sdk --goma --android --android-cpu=arm --android-cpu=arm64 --android-cpu=x64 --android-cpu=x86` done.
Running `ninja -C out/android_debug/ -j1000` in /usr/local/google/home/dacoharkes/flt/engine/src/.
  ninja: Entering directory `out/android_debug/'
  ninja: no work to do.
Command `ninja -C out/android_debug/ -j1000` done.

Build for emu (x86):

flutter_app/build/app/outputs/apk/debug$ unzip app-debug.apk 
Archive:  app-debug.apk
  inflating: res/layout/notification_action.xml  
 extracting: res/drawable-xhdpi-v4/notification_bg_normal.9.png  
  inflating: lib/armeabi-v7a/libmylib_dylib.so  
  inflating: res/layout/notification_template_icon_group.xml  
  inflating: kotlin/internal/internal.kotlin_builtins  
 extracting: res/drawable-xhdpi-v4/notification_bg_low_pressed.9.png  
  inflating: kotlin/reflect/reflect.kotlin_builtins  
 extracting: res/drawable-mdpi-v4/notify_panel_notification_icon_bg.png  
  inflating: res/layout-v17/notification_action.xml  
  inflating: META-INF/MANIFEST.MF    
  inflating: lib/arm64-v8a/libmylib_dylib_dependency.so  
  inflating: res/drawable/notification_bg_low.xml  
  inflating: res/layout-v16/notification_template_custom_big.xml  
  inflating: META-INF/app_debug.kotlin_module  
  inflating: lib/x86_64/libmylib_dylib_dependency.so  
 extracting: res/mipmap-hdpi-v4/ic_launcher.png  
  inflating: res/layout/notification_template_part_chronometer.xml  
  inflating: lib/x86_64/libmylib_dylib.so  
 extracting: META-INF/androidx.activity_activity.version  
  inflating: lib/armeabi-v7a/libmylib_dylib_dependency.so  
 extracting: META-INF/androidx.customview_customview.version  
 extracting: res/drawable-mdpi-v4/notification_bg_normal_pressed.9.png  
 extracting: resources.arsc          
  inflating: lib/armeabi-v7a/libflutter.so  
  inflating: kotlin/kotlin.kotlin_builtins  
  inflating: kotlin/coroutines/coroutines.kotlin_builtins  
  inflating: lib/x86/libmylib_source.so  
  inflating: lib/x86/libmylib_dylib.so  
  inflating: AndroidManifest.xml     
 extracting: META-INF/androidx.loader_loader.version  
 extracting: META-INF/androidx.lifecycle_lifecycle-livedata.version  
 extracting: META-INF/androidx.lifecycle_lifecycle-runtime.version  
 extracting: META-INF/androidx.viewpager_viewpager.version  
  inflating: assets/flutter_assets/kernel_blob.bin  
  inflating: lib/x86/libmylib_dylib_dependency.so  
 extracting: res/drawable-xhdpi-v4/notify_panel_notification_icon_bg.png  
 extracting: res/mipmap-mdpi-v4/ic_launcher.png  
 extracting: res/drawable-xhdpi-v4/notification_bg_low_normal.9.png  
 extracting: META-INF/androidx.tracing_tracing.version  
  inflating: res/layout-v21/notification_template_icon_group.xml  
  inflating: lib/arm64-v8a/libmylib_dylib.so  
  inflating: lib/armeabi-v7a/libmylib_source.so  
  inflating: res/layout/custom_dialog.xml  
  inflating: res/drawable/notification_icon_background.xml  
  inflating: kotlin/ranges/ranges.kotlin_builtins  
 extracting: res/mipmap-xxhdpi-v4/ic_launcher.png  
  inflating: META-INF/services/kotlinx.coroutines.CoroutineExceptionHandler  
  inflating: res/drawable-v21/notification_action_background.xml  
  inflating: res/drawable/notification_bg.xml  
 extracting: META-INF/androidx.window_window.version  
  inflating: lib/arm64-v8a/libmylib_source.so  
 extracting: META-INF/androidx.lifecycle_lifecycle-livedata-core.version  
  inflating: assets/flutter_assets/AssetManifest.json  
 extracting: META-INF/androidx.annotation_annotation-experimental.version  
 extracting: META-INF/androidx.window_window-java.version  
  inflating: assets/flutter_assets/isolate_snapshot_data  
  inflating: res/drawable-v21/launch_background.xml  
  inflating: res/layout-v17/notification_template_custom_big.xml  
  inflating: res/layout-v21/notification_action_tombstone.xml  
  inflating: META-INF/services/kotlinx.coroutines.internal.MainDispatcherFactory  
 extracting: res/drawable-mdpi-v4/notification_bg_low_normal.9.png  
  inflating: DebugProbesKt.bin       
 extracting: META-INF/androidx.versionedparcelable_versionedparcelable.version  
 extracting: res/drawable-mdpi-v4/notification_bg_low_pressed.9.png  
  inflating: META-INF/kotlinx-coroutines-android.kotlin_module  
 extracting: META-INF/androidx.savedstate_savedstate.version  
 extracting: META-INF/androidx.fragment_fragment.version  
  inflating: res/layout-v21/notification_action.xml  
  inflating: META-INF/kotlin-stdlib-jdk7.kotlin_module  
 extracting: res/drawable-hdpi-v4/notification_bg_normal_pressed.9.png  
  inflating: kotlin/collections/collections.kotlin_builtins  
  inflating: res/layout/notification_template_part_time.xml  
  inflating: META-INF/kotlinx-coroutines-core.kotlin_module  
 extracting: res/drawable-hdpi-v4/notify_panel_notification_icon_bg.png  
  inflating: assets/flutter_assets/shaders/ink_sparkle.frag  
  inflating: lib/x86_64/libmylib_source.so  
  inflating: assets/flutter_assets/vm_snapshot_data  
  inflating: assets/flutter_assets/fonts/MaterialIcons-Regular.otf  
  inflating: kotlin/annotation/annotation.kotlin_builtins  
 extracting: res/drawable-mdpi-v4/notification_bg_normal.9.png  
 extracting: res/mipmap-xhdpi-v4/ic_launcher.png  
  inflating: res/layout-v17/notification_action_tombstone.xml  
  inflating: assets/flutter_assets/FontManifest.json  
  inflating: META-INF/kotlin-stdlib-jdk8.kotlin_module  
  inflating: META-INF/annotation-experimental_release.kotlin_module  
  inflating: META-INF/window-java_release.kotlin_module  
  inflating: META-INF/CERT.SF        
 extracting: res/drawable-xhdpi-v4/notification_bg_normal_pressed.9.png  
  inflating: res/drawable/notification_tile_bg.xml  
 extracting: META-INF/androidx.lifecycle_lifecycle-viewmodel.version  
 extracting: res/drawable-hdpi-v4/notification_bg_low_normal.9.png  
  inflating: res/layout-v21/notification_template_custom_big.xml  
 extracting: META-INF/androidx.core_core.version  
 extracting: META-INF/androidx.arch.core_core-runtime.version  
  inflating: res/layout/notification_action_tombstone.xml  
  inflating: assets/flutter_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf  
  inflating: META-INF/window_release.kotlin_module  
  inflating: META-INF/kotlin-stdlib.kotlin_module  
  inflating: assets/flutter_assets/NOTICES.Z  
 extracting: res/mipmap-xxxhdpi-v4/ic_launcher.png  
  inflating: META-INF/kotlin-stdlib-common.kotlin_module  
  inflating: META-INF/CERT.RSA       
 extracting: res/drawable-hdpi-v4/notification_bg_low_pressed.9.png  
  inflating: classes.dex             
 extracting: res/drawable-hdpi-v4/notification_bg_normal.9.png  
  inflating: res/drawable/launch_background.xml 

Definitely the wrong libflutter.so, why though?

jason-simmons commented 2 years ago

Specifying multiple --android-cpu flags is not supported. The engine must be built separately for each target platform.

Also, some combinations are not going to work (e.g. doing a --runtime-mode=release build using AOT compilation with a target CPU like x86 where Dart does not support AOT)

dcharkes commented 2 years ago

Ah got it, I was building android_debug instead of android_debug_arm64, and passing android_debug instead of android_debug_arm64 as --local-engine.

Working setup:

Running `flutter/tools/gn --full-dart-sdk --no-prebuilt-dart-sdk --goma --android --android-cpu=arm --android-cpu=arm64` in /usr/local/google/home/dacoharkes/flt/engine/src/.
Running `ninja -C out/android_debug_arm64/ -j1000` in /usr/local/google/home/dacoharkes/flt/engine/src/.
flutter_app$ flutter run -d Nexus --local-engine=android_debug_arm64 --local-engine-src-path=/usr/local/google/home/dacoharkes/flt/engine/src

@jason-simmons should we error out on android_release, android_debug and android_debug_unopt without a CPU type? It seems that having gn and ninja not giving any error and selecting a CPU without telling us is kind of a footgun.

jason-simmons commented 2 years ago

If --android-cpu is not specified, then the flutter/tools/gn script defaults to 32-bit ARM (which is compatible with most Android devices)

dcharkes commented 2 years ago

I see, android_debug_arm doesn't exist.

I could have figured this out by reading the build files, but not so quickly. 🙃

Thanks for the help @jason-simmons !

phil10xs commented 2 years ago

Any real solution yet? I have the same issue in production on playstore console

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.