Closed dcharkes closed 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.
Specifying either a single or all --android-cpu
s 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?
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)
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.
If --android-cpu
is not specified, then the flutter/tools/gn
script defaults to 32-bit ARM (which is compatible with most Android devices)
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 !
Any real solution yet? I have the same issue in production on playstore console
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.
When trying to
run
on Android with--local-engine
on either device or emulator I get the errorjava.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:
Emulator:
Local engine build:
Devices:
Flutter version: