Skip to content

Cannot run in an emulator #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
janpietersh opened this issue Mar 6, 2022 · 10 comments
Closed

Cannot run in an emulator #352

janpietersh opened this issue Mar 6, 2022 · 10 comments

Comments

@janpietersh
Copy link

Describe the bug
Unable to open application on Android after following the install instructions for windows. I have been trying for a week now - have started over twice already.

To Reproduce
Steps to reproduce the behavior:

  1. Follow the install instructions
  2. Start the app in emulator and it crashes. Android warns about application repeatedly crashing.

Screenshots

npm run android

> Playground@0.0.1 android
> react-native run-android

info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 941 file(s) to forward-jetify. Using 16 workers...
info JS server already running.
info Installing the app...

> Task :babylonjs_react-native:externalNativeBuildDebug
Build multiple targets turbomodulejsijni_armeabi-v7a BabylonNative_armeabi-v7a
ninja: Entering directory `D:\github\brn\Modules\@babylonjs\react-native\android\.cxx\cmake\debug\armeabi-v7a'
[1/4] Building CXX object CMakeFiles/turbomodulejsijni.dir/4e5ecb00bdde94d1f4917926d71f51e2/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/CallInvokerHolder.cpp.o
[2/4] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\armeabi-v7a\libturbomodulejsijni.so
[3/4] Building CXX object CMakeFiles/BabylonNative.dir/src/main/cpp/BabylonNativeInterop.cpp.o
[4/4] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\armeabi-v7a\libBabylonNative.so
Build multiple targets turbomodulejsijni_arm64-v8a BabylonNative_arm64-v8a
ninja: Entering directory `D:\github\brn\Modules\@babylonjs\react-native\android\.cxx\cmake\debug\arm64-v8a'
[1/4] Building CXX object CMakeFiles/turbomodulejsijni.dir/4e5ecb00bdde94d1f4917926d71f51e2/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/CallInvokerHolder.cpp.o
[2/4] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\arm64-v8a\libturbomodulejsijni.so
[3/4] Building CXX object CMakeFiles/BabylonNative.dir/src/main/cpp/BabylonNativeInterop.cpp.o
[4/4] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\arm64-v8a\libBabylonNative.so
Build multiple targets BabylonNative_x86 turbomodulejsijni_x86
ninja: Entering directory `D:\github\brn\Modules\@babylonjs\react-native\android\.cxx\cmake\debug\x86'
[1/4] Building CXX object CMakeFiles/turbomodulejsijni.dir/67c9fccfe50064556a8f170889e24543/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/ReactCommon/CallInvokerHolder.cpp.oeact/turbomodule/core/jni/ReactCommon/CallInvokerHolder.cpp.o
[2/4] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\x86\libturbomodulejsijni.so
[3/4] Building CXX object CMakeFiles/BabylonNative.dir/src/main/cpp/BabylonNativeInterop.cpp.o
[4/4] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\x86\libBabylonNative.so

> Task :app:installDebug
Installing APK 'app-debug.apk' on 'Pixel_4_API_31(AVD) - 12' for app:debug
Installed on 1 device.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 35s
87 actionable tasks: 7 executed, 80 up-to-date
info Connecting to the development server...
info Starting the app on "emulator-5554"...
Starting: Intent { cmp=com.playground/.MainActivity }

adb logcat

...
03-05 17:47:45.725 10991 11040 I ReactNativeJS: Running "Playground" with {"rootTag":1}
03-05 17:47:45.780  8775  8783 W id.gms.unstabl: Reducing the number of considered missed Gc histogram windows from 228 to 100
03-05 17:47:46.165 10991 10991 W com.playground: Accessing hidden field Landroid/view/View;->mAccessibilityDelegate:Landroid/view/View$AccessibilityDelegate; (unsupported, reflection, allowed)
03-05 17:47:46.206 10991 11040 D SoLoader: About to load: libturbomodulejsijni.so
03-05 17:47:46.207 10991 11040 D SoLoader: libturbomodulejsijni.so not found on /data/user/0/com.playground/lib-main
03-05 17:47:46.207 10991 11040 D SoLoader: libturbomodulejsijni.so found on /data/app/~~ejGtoX97SPL77JdqbXL77A==/com.playground-jWAwwWJfZ3XhFVaeHTc-sQ==/lib/x86_64
03-05 17:47:46.207 10991 11040 D SoLoader: Not resolving dependencies for libturbomodulejsijni.so
03-05 17:47:46.209 10991 11040 D SoLoader: Loaded: libturbomodulejsijni.so
03-05 17:47:46.213 10991 11040 E AndroidRuntime: FATAL EXCEPTION: mqt_js
03-05 17:47:46.213 10991 11040 E AndroidRuntime: Process: com.playground, PID: 10991
03-05 17:47:46.213 10991 11040 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libBabylonNative.so" not found
03-05 17:47:46.213 10991 11040 E AndroidRuntime:        at java.lang.Runtime.loadLibrary0(Runtime.java:1077)
...

Other

  • Android
  • node --version --> v16.13.2
  • npm --version --> 8.1.2
  • cmake version 3.19.6 (latest version was causing errors as per other issues)
@bghgary
Copy link
Contributor

bghgary commented Mar 7, 2022

This might be better asked on the forum. I have never seen this error before. Do you have a physical device to try in case it is emulator specific?

Also, just in case it matters, what version of Android Studio are you using and what version of the NDK are you targeting?

@janpietersh
Copy link
Author

thanks @bghgary for helping.

Android Studio Bumblebee - 2021.1.1 Patch 2
I only have NDK 21.3.6528147 installed (same as specified in apps/playground/0.64/android/build.gradle)

How are those .so files linked? I don't see why my program cannot see them.

@janpietersh
Copy link
Author

Could somebody share versions of above programs that do work?

@ryantrem
Copy link
Member

ryantrem commented Mar 9, 2022

Here are my Android Studio and NDK versions, and I didn't run into any issues last time I rebuilt:

image

image

If I recall, the output .so is supposed to be included in the packaging by virtue of the project being pulled in as part of the RN auto linking. I don't think there is any Babylon React Native specific configuration for that if I recall.

@ryantrem
Copy link
Member

ryantrem commented Mar 9, 2022

I wonder if something changed in the tooling and native libs are no longer automatically packaged in the app bundle or something? I saw some questions on Stack Overflow that sounded maybe similar, with some references to a gradle property called useLegacyPackaging, but not sure if this is really related or not.

@janpietersh
Copy link
Author

I installed Android Studio 4.1.3 and re-installed Babylon React Native from latest source. This is what I am getting right now on npm run android.

[2/4] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\x86\libturbomodulejsijni.so
[3/4] Building CXX object CMakeFiles/BabylonNative.dir/src/main/cpp/BabylonNativeInterop.cpp.o
[4/4] Linking CXX shared library ..\..\..\..\build\intermediates\cmake\debug\obj\x86\libBabylonNative.so

> Task :app:installDebug
Installing APK 'app-debug.apk' on 'Pixel_4_API_30(AVD) - 11' for app:debug
Installed on 1 device.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 34s
87 actionable tasks: 8 executed, 79 up-to-date
info Connecting to the development server...
warn Failed to connect to development server using "adb reverse": spawnSync %LOCALAPPDATA%\Android\sdk/platform-tools/adb ENOENT
info Starting the app on "emulator-5554"...
The system cannot find the path specified.
error Failed to start the app. Run CLI with --verbose flag for more details.
Error: Command failed: %LOCALAPPDATA%\Android\sdk/platform-tools/adb -s emulator-5554 shell am start -n com.playground/com.playground.MainActivity

Is this not meant to work on windows - it looks like the path separators are for linux/mac. Also adb is in my path.

When I run adb logcat I am seeing this:

03-13 22:35:33.305  9479  9527 I ReactNativeJS: Running "Playground" with {"rootTag":1}
03-13 22:35:33.909  9479  9479 W com.playground: Accessing hidden field Landroid/view/View;->mAccessibilityDelegate:Landroid/view/View$AccessibilityDelegate; (greylist, reflection, allowed)
03-13 22:35:33.963  9479  9527 D SoLoader: About to load: libturbomodulejsijni.so
03-13 22:35:33.963  9479  9527 D SoLoader: libturbomodulejsijni.so not found on /data/user/0/com.playground/lib-main
03-13 22:35:33.963  9479  9527 D SoLoader: libturbomodulejsijni.so found on /data/app/~~XoMmwgHCITeG1qfzLc0Uww==/com.playground-66Vz9PZzTvMKg6DHLry3Xw==/lib/x86
03-13 22:35:33.963  9479  9527 D SoLoader: Not resolving dependencies for libturbomodulejsijni.so
03-13 22:35:33.965  9479  9527 D SoLoader: Loaded: libturbomodulejsijni.so
03-13 22:35:34.071  9479  9479 D HostConnection: HostConnection::get() New Host Connection established 0xf4804ae0, tid 9479
03-13 22:35:34.075  9479  9479 D HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2
03-13 22:35:34.075  9479  9479 D         : D:/github/brn/Modules/@babylonjs/react-native/submodules/BabylonNative/Dependencies/bgfx.cmake/bgfx/src/glcontext_egl.cpp (235): BGFX 0x00000002: eglChooseConfig
03-13 22:35:34.075  9479  9479 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 9479 (com.playground), pid 9479 (com.playground)

It is opening the app very briefly. I can see the button for XR and then it crashes. Maybe this is progress since the errors are different?!

@bghgary
Copy link
Contributor

bghgary commented Mar 14, 2022

Is this not meant to work on windows

Most of us run Android Studio on Windows. I don't know why you are seeing all of these issues. I'm using Android Studio Arctic Fox | 2020.3.1 Patch 3 right now if that helps.

@janpietersh
Copy link
Author

thanks it seems to work on a real device and not emulator. i managed to borrow a device, but I do not have an android device. does this mean that I cannot develop with an emulator - is anybody able to work with an emulator?

@janpietersh janpietersh changed the title "libBabylonNative.so" not found Cannot run in an emulator Mar 18, 2022
@ryantrem
Copy link
Member

ryantrem commented Mar 18, 2022

@janpietersh can you try these steps for troubleshooting Android emulator issues? https://github.com/BabylonJS/BabylonNative/blob/master/Documentation/AndroidEmulator.md

Specifically, check the OpenGL ES3 section first.

We have a Babylon React Native related issue for getting this documented in a way that people can easily find it from the BRN docs, but we haven't addressed it yet.

@janpietersh
Copy link
Author

thanks @ryantrem - did not find that emulator link before! 😄 in addition I believe the path separators was because i was using a cmd instead of powershell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants