Skip to content
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

App crash on Android device, with error "libgnustl_shared.so is 32-bit instead of 64-bit" #12

Open
gabeljz opened this issue Feb 26, 2019 · 8 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@gabeljz
Copy link

gabeljz commented Feb 26, 2019

App created with create-rx-app will crash immediately upon launch on a physical Android device. The run log in Android Studio shows the error message "libgnustl_shared.so is 32-bit instead of 64-bit".

Expected the app to run on a physical Android device without any problem, just like running in the simulator.

Environment set up

  • create-rx-app: 0.4.15
  • react-native-cli: 2.0.1
  • react-native: 0.57.8
  • node: v10.15.0
  • npm: 6.7.0
  • yarn: 1.13.0
  • Android Studio 3.3, Build #AI-182.5107.16.33.5199772, built on December 25, 2018
  • JRE: 1.8.0_152-release-1248-b01 x86_64
  • JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
  • macOS: 10.14.2
  • Physical device 1: Sony E6853 (Android 7.1.1, API 25)
  • Physical device 2: LGE LG-H815 (Android 6.0, API 23)

I am able to run Android apps from other projects on these two physical devices via Android Studio or react-native run-android, so the problem is unlikely to be caused by my environment set up. Projects whose Android app can be successfully run on both physical devices:

Steps to reproduce the error

  1. create-rx-app fresh
  2. cd fresh
  3. connect android device with debugging enabled, adb devices to confirm that the device is detected.
  4. adb reverse tcp:8081 tcp:8081
  5. yarn start:rn-dev-server
  6. Open "./android" in Android Studio, and wait for the configuration to load completely.
  7. Press the green triangular "Run" button.
  8. Choose the physical device.
  9. The app starts on the device, showing "Loading from localhost:8081" with a green background.
  10. The packager, Metro Bundler, starts to build and serve the bundle.
  11. Once the serving of the bundle reached 100%, the app will crash.

Note: This freshly created reactxp app can run successfully on Android simulator without any problems.

Run log from Android Studio

02/26 15:01:23: Launching app
$ adb install-multiple -r -t /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/dep/dependencies.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_6.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_0.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_5.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_1.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_2.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_3.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_4.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_9.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_7.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/split-apk/debug/slices/slice_8.apk /Users/gabe/pm/react-native/rx/fresh/android/app/build/intermediates/instant-run-apk/debug/app-debug.apk 
Split APKs installed in 3 s 839 ms
$ adb shell am start -n "com.fresh/com.fresh.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 25916 on device sony-e6853-CB5A2BF4PC
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
D/ReactNative: ReactInstanceManager.onJSBundleLoadedFromServer()
D/ReactNative: ReactInstanceManager.recreateReactContextInBackground()
    ReactInstanceManager.runCreateReactContextOnNewThread()
D/SoLoader: About to load: libreactnativejni.so
    libreactnativejni.so found on /data/data/com.fresh/lib-main
D/SoLoader: Loading lib dependencies: [libglog_init.so, libyoga.so, libprivatedata.so, libfb.so, libfolly_json.so, libjsc.so, libglog.so, libgnustl_shared.so, libandroid.so, liblog.so, libstdc++.so, libm.so, libc.so, libdl.so]
    About to load: libglog_init.so
    libglog_init.so found on /data/data/com.fresh/lib-main
D/SoLoader: Loading lib dependencies: [libglog.so, libgnustl_shared.so, liblog.so, libstdc++.so, libm.so, libc.so, libdl.so]
    About to load: libglog.so
    libglog.so found on /data/data/com.fresh/lib-main
D/SoLoader: Loading lib dependencies: [libgnustl_shared.so, libstdc++.so, libm.so, libc.so, libdl.so]
    About to load: libgnustl_shared.so
    libgnustl_shared.so found on /data/data/com.fresh/lib-main
D/SoLoader: Loading lib dependencies: [libm.so, libc.so, libdl.so]
    About to load: libm.so
    libm.so not found on /data/data/com.fresh/lib-main
D/SoLoader: libm.so not found on /data/app/com.fresh-1/lib/arm64
    libm.so not found on /system/vendor/lib
    libm.so found on /system/lib
    libm.so loaded implicitly
    Loaded: libm.so
    About to load: libc.so
    libc.so not found on /data/data/com.fresh/lib-main
    libc.so not found on /data/app/com.fresh-1/lib/arm64
    libc.so not found on /system/vendor/lib
    libc.so found on /system/lib
    libc.so loaded implicitly
    Loaded: libc.so
D/SoLoader: About to load: libdl.so
    libdl.so not found on /data/data/com.fresh/lib-main
    libdl.so not found on /data/app/com.fresh-1/lib/arm64
    libdl.so not found on /system/vendor/lib
    libdl.so found on /system/lib
    libdl.so loaded implicitly
    Loaded: libdl.so
E/SoLoader: Error when loading lib: dlopen failed: "/data/data/com.fresh/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit lib hash: 38a149cf3f94c06f35444ea1c5280541 search path is /data/app/com.fresh-1/lib/arm64
    couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.fresh/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
    couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.fresh/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
    couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.fresh/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
    couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.fresh/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
E/AndroidRuntime: FATAL EXCEPTION: Thread-4
    Process: com.fresh, PID: 25916
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.fresh/lib-main/libgnustl_shared.so" is 32-bit instead of 64-bit
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:703)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:564)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:500)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:455)
        at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:18)
        at com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:19)
        at com.facebook.react.bridge.JSCJavaScriptExecutorFactory.create(JSCJavaScriptExecutorFactory.java:21)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:917)
        at java.lang.Thread.run(Thread.java:761)
Application terminated.
@a-tarasyuk a-tarasyuk added bug Something isn't working help wanted Extra attention is needed labels Mar 1, 2019
@lior-frezi
Copy link

lior-frezi commented Mar 7, 2019

this helped for me:
open ./android /app /build.gradle
add

ndk {  
    abiFilters "armeabi-v7a", "x86"  
}

under

android {
    ...
    defaultConfig {
    ...

@a-tarasyuk
Copy link
Owner

@liorJuice Do you want to make PR :)? If this solution works well for emulator and devices, it can be merged into the Android template.

@gabeljz
Copy link
Author

gabeljz commented Mar 8, 2019

Suggested fix allows the app to run on a physical Android device

@liorJuice , thank you very much for your fix!

After applying your fix, I managed to run an app freshly created with create-rx-app on physical Android device, LGE LG-H815 (Android 6.0, API 23).

Now that you have pointed out this setting, I just checked that the ./android/app/build.gradle for every reactxp's sample project, and indeed the abiFilters "armeabi-v7a", "x86" is in every one of them:

Effects of abiFilters "armeabi-v7a", "x86"

I am trying to understand the effects of abiFilters "armeabi-v7a", "x86". On NdkOptions - Android Plugin 3.3.0 DSL Reference

When this flag is not configured, Gradle builds and packages all available ABIs.

Seems like the omitted ABIs in abiFilters "armeabi-v7a", "x86", are:

  • armeabi
  • arm64-v8a
    • armeabi-v7a libraries should also run on processors with arm64-v8a instruction set. So it should be safe to omit "arm64-v8a" for now.
  • x86_64
    • This is the 64-bits version of x86 instruction set. The 32 bits x86 libraries should also run on 64 bits processors. So it should be safe to omit "x86_64" for now.

I am very new to all these. Please feel free to correct me if I misunderstood anything.

64-bits version of apps required on the Google Play store from August 2019

On Android Developers Blog: Improving app security and performance on Google Play for years to come, it is announced that:

In August 2019, Play will require that new apps and app updates with native libraries provide 64-bit versions in addition to their 32-bit versions.

So does that mean that we have to add "x86_64", "arm64-v8a" by August 2019? Will that causes any problem then?

I tried including either "x86_64" or "arm64-v8a" to the abiFilters, then run react-native run-android:

  • "x86_64" - The app builds and runs on the physical Android device successfully.
  • "arm64-v8a" - The app crashes upon launch as detailed in the main description of this issue.

Does this mean that we would not be able to publish any new apps or updates from August 2019 onwards?

Is this problem occurring with reactxp?

An app freshly created with react-native init does not have abiFilters "armeabi-v7a", "x86" in its ./android/app/build.gradle file. It includes all available ABIs and will still run successfully on the same physical Android device.

Is this problem caused by using reactxp? Any chance that all necessary 64 bits libraries can be provided?

Side note: "x86-64", instead of "x86_64", is written

"x86-64", instead of "x86_64", is written in ./android/app/build.gradle in an app freshly created by create-rx-app, at two locations:

  • In android > splits > abi > include
  • In the nested function in android > applicationVariants.all

I am not sure if "x86-64" is a valid value, or it should be "x86_64".

I do not have an Intel-based Android device to test if the app can actually run on 64 bits x86 processor.

@a-tarasyuk
Copy link
Owner

Published new version which includes abiFilters

@gabeljz
Copy link
Author

gabeljz commented Mar 13, 2019

Is there any plan to release the 64 bits libraries to meet Google's Play store requirement?

In August 2019, Play will require that new apps and app updates with native libraries provide 64-bit versions in addition to their 32-bit versions.

@gabeljz
Copy link
Author

gabeljz commented Mar 25, 2019

@a-tarasyuk , There hasn't been any activity on this issue. Is it more appropriate if I a post new request for 64 bits libraries for Android on https://github.com/Microsoft/reactxp/issues ?

@a-tarasyuk
Copy link
Owner

@gabeljz create-rx-app uses base RN template with several changes to work on ReactXP environment because under the hood ReactXP uses RN. If RN has 64 bits libraries support, it should work in ReactXP as well.

@Balajipss
Copy link

Balajipss commented Aug 25, 2019

Using RN 0.60.5 version.
If you guys are wondering why your app crashes if you download it from playstore, make the below changes

packagingOptions {
exclude '/lib/arm64-v8a/libc++_shared.so' (exclude '/lib/arm64-v8a/error_causing_library.so')
exclude '/lib/x86_64/libc++_shared.so' (exclude '/lib/arm64-v8a/error_causing_library.so')

//In pickFirst, replace the library name with the library that is causing error.
pickFirst '/lib/x86/libc++_shared.so' (pickFirst '/lib/x86/error_causing_library.so')
pickFirst '/lib/armeabi-v7a/libc++_shared.so' (pickFirst '/lib/armeabi-v7a/error_causing_library.so')
}

If you do not know which library is causing the crash, upload your bundle in Firebase test lab and then check. It will tell you which library is throwing the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants