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

New app crashes enabling Hermes on Android emulators with API <= 19 #25646

Closed
lcarrettin opened this issue Jul 14, 2019 · 16 comments
Closed

New app crashes enabling Hermes on Android emulators with API <= 19 #25646

lcarrettin opened this issue Jul 14, 2019 · 16 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot. Tech: Hermes Hermes Engine: https://hermesengine.dev/

Comments

@lcarrettin
Copy link

Enabling Hermes in a new app created from scratch, the app crashes at startup on Android x86 emulators from API 16 to 19.

This is the logcat in case of a debug build:

07-14 17:03:50.673 2028-2068/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
java.lang.ExceptionInInitializerError
at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so caused by: Cannot load library: reloc_library[1306]: 1170 cannot locate 'sigemptyset'...

    at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
    at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
    at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27) 
    at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949) 
    at java.lang.Thread.run(Thread.java:856) 

The Release variant shows different errors based on the emulator API level. For example:

  • API 16
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so caused by: Cannot load library: reloc_library[1306]: 1170 cannot locate 'sigemptyset'...
  • API 19
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so caused by: dlopen failed: cannot locate symbol "posix_fallocate" referenced by "libhermes.so"...

The app doesn't crash if API > 19.

React Native version:
System:
OS: macOS 10.14.5
CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
Memory: 1.79 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.14.1 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
Android NDK: 20.0.5594570
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5692245
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.3 => 0.60.3
npmGlobalPackages:
react-native-cli: 2.0.1

Steps To Reproduce

  1. Create a new app:
    react-native init AwesomeProject
  2. Enable Hermes as explained in the guide
  3. Run the app on an Android x86 emulator from API 16 to 19.

Describe what you expected to happen:
the app shouldn't crash.

Snack, code example, or link to a repository:

@lcarrettin lcarrettin added the Bug label Jul 14, 2019
@react-native-bot react-native-bot added the Platform: Android Android applications. label Jul 14, 2019
@YajanaRao
Copy link

YajanaRao commented Jul 15, 2019

Similar Error when I update from react native 0.60 to 0.60.3

 couldn't find DSO to load: libhermes.so
E AndroidRuntime: FATAL EXCEPTION: create_react_context
E AndroidRuntime: Process: com.serenity, PID: 6296
E AndroidRuntime: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so    
E AndroidRuntime: 	at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
E AndroidRuntime:        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
E AndroidRuntime:        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)    
E AndroidRuntime:  	at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)   
E AndroidRuntime:        at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
E AndroidRuntime:        at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27)
E AndroidRuntime:        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
E AndroidRuntime:        at java.lang.Thread.run(Thread.java:764)

react native info

System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i3-7100 CPU @ 3.90GHz
    Memory: 1.09 GB / 7.91 GB
  Binaries:
    Node: 10.15.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.16.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
    Watchman: 4.9.0 - C:\Shortcut\watchman.EXE
  SDKs:
    Android SDK:
      Android NDK: 15.2.4203891
  IDEs:
    Android Studio: Version  3.4.0.0 AI-183.6156.11.34.5522156

@react-native-bot react-native-bot added the Tech: Hermes Hermes Engine: https://hermesengine.dev/ label Jul 17, 2019
@nawartamawi
Copy link

similar issue app builds successfully tries to load a module from the metro bundle but crashes on startup.

E/SoLoader: couldn't find DSO to load: libhermes.so
E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.bluescapemobile, PID: 10158
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
        at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
        at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
        at java.lang.Thread.run(Thread.java:919)

@lachtos
Copy link

lachtos commented Jul 23, 2019

RN 0.60.4 with Hermes enabled

FATAL EXCEPTION: create_react_context
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so caused by: dlopen failed: cannot locate symbol "posix_fallocate" referenced by "libhermes.so"...
	at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
	at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
	at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
	at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
	at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
	at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27)
	at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
	at java.lang.Thread.run(Thread.java:841)

@cpojer
Copy link
Contributor

cpojer commented Jul 23, 2019

See facebook/hermes#42

@cpojer cpojer closed this as completed Jul 23, 2019
@msqar
Copy link

msqar commented Jul 25, 2019

Any news on this?

@denieler
Copy link

denieler commented Sep 1, 2019

Guys, had the same issue, but after a while double-checked migration guide https://react-native-community.github.io/upgrade-helper/?from=0.59.9&to=0.60.5 and realized I've made a mistake in android/app/build.gradle, so please double-check your code

@msqar
Copy link

msqar commented Sep 1, 2019

@denieler yes, after copying the code from 0.60.4/0.60.5 my app works again without any issues. Although.. it is complaining about Gradle 6 when i react-native run-android.

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

Happens the same for you?

@denieler
Copy link

denieler commented Sep 1, 2019

@msqar no, this one is not happening for me if I'm not mistaken

@mtkopone
Copy link

mtkopone commented Sep 2, 2019

Android 4.4
ReactNative 0.60.5

Creating a fresh app with "react-native init" and enabling hermes in android/app/build.gradle:80 still results in this crash when running the debug variant.

Running with "react-native run-android --variant=release" causes the "java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so caused by: dlopen failed: cannot locate symbol "posix_fallocate" referenced by "libhermes.so" crash.

@jsaraiva
Copy link

jsaraiva commented Sep 2, 2019

Hello.

Have you tried using hermes-engine 0.1.1 ?

yarn add hermes-engine --dev

After adding that, you'll have to edit android/app/build.gradle with the following changes:

  1. Enable Hermes (I assume you've done this already), and tell the react compiler where to find the new hermes engine module:
    project.ext.react = [
    entryFile: "index.js",
    enableHermes: true, // clean and rebuild if changing
    hermesCommand: "../../node_modules/hermes-engine/%OS-BIN%/hermes",
    ]

  2. Adjust the dependencies for the new module (replace "hermes-vm" with "hermes-engine"):

    if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
    implementation jscFlavor
    }

I personally don't have any Android 4.4 device for testing. However, a couple of days ago I submitted an app with RN 0.60.5 + Hermes, and the Google Play Pre-launch Report ran it in an Android 4.3 device with no problems whatever.

Cheers!

@mtkopone
Copy link

mtkopone commented Sep 2, 2019

THANK YOU @jsaraiva !

@arjun-mavonic
Copy link

@jsaraiva Does it not work on hermes-engine 0.2.1 which is the current latest?

@jsaraiva
Copy link

@jsaraiva Does it not work on hermes-engine 0.2.1 which is the current latest?

Personally, I haven't tested it yet (busy with other projects). But I see no reason why it shouldn't.
I only mentioned the version because version 0.1.0 was still hermes-vm, which was the component causing problems; hermes-engine itself actually started at 0.1.1.
Note that the "yarn add hermes-engine --dev" command I posted did not mention the version.

Cheers!

@arjun-mavonic
Copy link

arjun-mavonic commented Oct 10, 2019

Yes.. So 0.2.1 got installed. But it did not work for me. Anyways thanks.
Turned off the hermes option for now. App is working fine

@jsaraiva
Copy link

Have you tried specifying the older version specifically? (in package.json, specifying
"hermes-engine": "0.1.1"
instead of
"hermes-engine": "^0.2.1"
and running yarn again)

Maybe the devs introduced some new bugs into the engine. It happens.

@wmonecke
Copy link

wmonecke commented Aug 10, 2020

This same error is happening to me on Android Devices running Android 10 (Pixel 4, for example).
I tried the solution proposed above but got the following error after cleaning and trying to build:

> A problem occurred starting process 'command '../../node_modules/hermes-engine/osx-bin/hermes''

When I check node_modules I don't see hermes inside osx-bin. What happened here? Where should I point the path to?

I am using hermes-engine: 0.6.0

Screenshot of folder of hermes-engine: 0.6.0:

Screenshot 2020-08-11 at 00 06 28

EDIT it seems this only works with hermes-engine: 0.1.1

@facebook facebook locked as resolved and limited conversation to collaborators Oct 8, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot. Tech: Hermes Hermes Engine: https://hermesengine.dev/
Projects
None yet
Development

No branches or pull requests