react-native: [0.60.3] App crash on startup when enabling Hermes (enableHermes: true)
App is crashing when I enable Hermes in android/app/build.gradle. App is working fine with react-native 0.60.3 with enableHermes: false
Error:
07-12 08:06:59.097 20330-20330/com.reactnativememoryprofile E/SoLoader: couldn't find DSO to load: libjscexecutor.so 07-12 08:06:59.123 20330-20345/com.reactnativememoryprofile E/SoLoader: couldn't find DSO to load: libhermes.so 07-12 08:06:59.124 20330-20345/com.reactnativememoryprofile E/AndroidRuntime: FATAL EXCEPTION: create_react_context Process: com.reactnativememoryprofile, PID: 20330 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:818)
React Native version: System: OS: macOS 10.14.5 CPU: (12) x64 Intel® Core™ i7-8750H CPU @ 2.20GHz Memory: 373.31 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.1 - /usr/local/bin/node Yarn: 1.13.0 - /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: API Levels: 23, 24, 25, 26, 27, 28 Build Tools: 21.1.2, 23.0.1, 25.0.0, 25.0.1, 25.0.2, 26.0.2, 26.0.3, 27.0.3, 28.0.0, 28.0.2, 28.0.3, 29.0.0 System Images: android-23 | Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-27 | Android TV Intel x86 Atom, android-27 | Intel x86 Atom, android-27 | Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64 Android NDK: 20.0.5594570 IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: 10.2/10E125 - /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 react-native-create-library: 3.1.2 react-native-git-upgrade: 0.2.7 m-c02xf2cejg5h:reactNativeMemoryProfi
Steps To Reproduce
- Follow the steps mentioned in hermes
- react-native run-android --variant release
Describe what you expected to happen: App should not crash
Snack, code example, or link to a repository:
https://github.com/bhaskarGyan/react-native-memory-profile/tree/bug/rn-0.60.3_hermes
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 49
- Comments: 122 (7 by maintainers)
Same issues
If you have additional build types those will need to be added too, e.g.
Because we have a few build types, and apart from debug they should all be in release mode, I also had to add some react.gradle fixes. We have a custom react.gradle so this wasn’t too much trouble. Basically changing
targetName.toLowerCase().contains("release")
to!targetName.toLowerCase().contains("debug")
.and
Also added a quick fix for #25609
you’ll need to add
at the top of your
build.gradle
file andin your dependencies.
Should we move those bits of configuration to
react.gradle
?In my case I saw this crash when:
enableHermes: false
enableHermes: true
all while
and
were present.
Crash disappears after cleaning the build:
cd android && ./gradlew clean
The same thing is happening to me, the build is successful, but:
2019-07-12 09:26:37.060 4759-4796/com.tests E/SoLoader: couldn't find DSO to load: libhermes.so --------- beginning of crash 2019-07-12 09:26:37.062 4759-4796/com.sherlock E/AndroidRuntime: FATAL EXCEPTION: create_react_context Process: com.tests, PID: 4759 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:764)
If you enable hermes - you will get 2x error
couldn't find DSO to load: libhermes.so
If you disable hermes - you will get only oncecouldn't find DSO to load: libhermes.so
So in conclusion you cant disable that nonsense and your app will crash no matter what. Seems like we will have to wait for a year or so until they come up with the proper documentation on how to upgrade to RN 6
I’ve been able to follow these steps to get split APKs and universal APKs launching correctly for staging and release builds. I have not been able to get it working for .aab bundles. I build the bundle and when I install the application, it results in a hanging white screen on startup. Has anybody come across a similar issue?
same issue here it builds fine but crashes on start up
I, following the guide set enableHermes to true but cant see any global variable named HermesInternal.
Install Hermes Engine. NPM
@SourceCipher Yes, it works, these are the bits from my app/build.gradle
After that, though I ran into red screen issues connecting to 10.0.2.2:8081, which I solved by modifying AndroidManifest.xml:
In my case I had “hermes-engine” folder instead of “hermesvm” under node_modules so when I changed the folder name to hermes-engine in the app’s build.gradle the error was gone (my RN version is 0.61.0)
on RN 0.61.1 this problem seems resolved so i would suggest upgrading your RN version.
1-upgrade react-native to 0.61 2-enable hermes
3-add in android/app/build.gradle
Still an issue on 0.61.0 aswell.
My working solution (using
RN 0.60.4
)build.gradle
, changeto
and
to
hermes-engine
(0.1.1)@HarshitMadhav I got the same error as you were
In your case, I think you should check step 2 to change
hermesPath
It is now working. Problem: I made a mistake not to refer to https://github.com/react-native-community/rn-diff-purge/compare/release%2F0.60.0..release%2F0.60.3?diff=split while upgrading the App from 0.60.0 to 0.60.3.
After modification of relevent file mentioned in above url and cd android && ./gradlew clean, the app is working as expected with Hermes enabled.
Link to commit in my repo for these changes -> https://github.com/bhaskarGyan/react-native-memory-profile/commit/3d05ebc0391217c39d6615f6e2c1804890d69f5c
@bhaskarGyan I init project from react native cli, with version 0.60.3, and still meet the problem with
couldn't find DSO to load: libhermes.so
Any clue for that?
Thanks
@SourceCipher And the issue is CLOSED. Boom.
@Devlin556 did you copy react.gradle from
node_modules/react-native/react.gradle
toandroid/app/react.gradle
?When you’ve done that, make the two changes shown above - both involve changing
targetName.toLowerCase().contains("release")
to!targetName.toLowerCase().contains("debug")
Probably worth running
(cd android && ./gradlew clean)
afterwards too before trying to build again.BTW I haven’t tried RN 0.61 yet but in my few hours experience with Hermes, my impression was that this isn’t really ready for production use, given that it doesn’t even work on a fresh 0.60.5 app without multiple workarounds. It’s also super slow (maybe 3-5x slowdown) compared to JSC in debug mode with our app and I experienced some crashes. Assuming Facebook are using this internally I’m sure the situation will improve rapidly though.
Same problem here, using RN 0.60.3.
I followed this (https://react-native-community.github.io/upgrade-helper/?from=0.59.9&to=0.60.3) to upgrade my app from RN 0.59.9 to 0.60.3 and have added all the necessary configs for Android from there.
The app runs normally when Hermes is not enabled. However, once Hermes is enabled by following the step here (https://facebook.github.io/react-native/docs/hermes), the app can build, can start up and show the splash screen - but crashes immediately after the splash screen is done. Couldn’t find any solution yet. Hope this provides a bit of extra information needed to debug this.
Same issue after setting: project.ext.react = [ entryFile: “index.js”, enableHermes: true // clean and rebuild if changing ] App build fine but crash on startup :
Fatal Exception: java.lang.UnsatisfiedLinkError com.facebook.soloader.SoLoader.doLoadLibraryBySoName
Thanks @aliozinan !
I’m on RN 0.61.2 and fixed by replacing
hermesvm
withhermes-engine
inandroid/app/build.gradle
, like this:def hermesPath = "../../node_modules/hermes-engine/android/";
Now everything works properly.
For anyone having this issue, this may help.
From React native docs:
That means Hermes is only for
.apk
. I was really had a headache because my release.aab
stucks on splash screen 🤣Hope this help
For people with more build types (let’s call it anotherDebug):
Can somebody open up this issue. There are still lots of us with this problem? Cc: @bhaskarGyan
Has anyone been successful at running a release version with Hermes enabled from the Play Store?
I can run a
react-native run-android --variant release
build on my phone without issue, but if I do a./gradlew bundleRelease
and upload the aab file to the Google store, when I attempt to run that version on my phone, I just get a black screen after a long delay.Firebase Crashlytics shows the following:
Any thoughts?
I think I passed this issue, via ./gradlew clean, but now I have problem same as #25599 when run with --variant release
This worked for me!
Herms is still not working on release variant in react native “0.60.5” on
react-native init
project. Debug variant is fine.Should be this as of
RN 0.60.4
@maitrungduc1410 oh my god, I’ve been banging my head on the wall for hours with that.
That being said, it now says:
Android app bundles are supported from react-native 0.62.0 and up.
so 0.63.2 shouldn’t be affected.After enabling Hermes in your project, Please update the Hermes path in “android/app/build.gradle” file. You can see the sample code below.
After the update of hermesPath, run your application
react-native run-android
. Hermes issue has been fixed.I do have the same issue
// @benoitdion where are we initialising the variable jscFlavor?
@benoitdion, If possible then Yes please since I believe user should not be worried about these kind of one time configuration. It would be great if these bits of config move to react.gradle
This solved my issue, thank you @nokite .
I solved this by four steps.
project.ext.react = [ entryFile: "index.js", enableHermes: false, // clean and rebuild if changing ]
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
if (enableHermes) { def hermesPath = "../../node_modules/hermesvm/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor }
2. npm install hermesvm 3. changeenableHermes: false
toenableHermes: true
4. clean project and rebuild,then successI alse have a question.When set ‘enableHermes’ to false,that means i don’t want to use hermes,i also got the problem.That confused me a lot.
Just resolved that issue on my side. The problem was when I assemble with buildType “releaseStaging”. I added : releaseStagingImplementation files(hermesPath + “hermes-release.aar”) near to
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
Thanks for helping bro. I’ve resolved my issue too.
You saved my life. Thanks a lot =)
Don’t forget to add
def jscFlavor = 'org.webkit:android-jsc:+'
@ebwinters I think you should edit the next code:
to this:
worked for me after following rn-diff-purge
https://github.com/react-native-community/rn-diff-purge/compare/release/0.59.10..release/0.60.3
@mjmasn After update to the latest version RN@0.60.3
I have got this error when I run my app
And in my project I do not enable Hermes!
I had the exact same issue, with none of the steps above working. I eventually realized that when I ran
npx react-native upgrade
I had some conflicts that never made it to the diff. By examining rn-diff-purge I was able to apply the manual updates needed to my build.gradle files, gradle-wrapper, and other android areas. It now works as expected!Same issue here.
java.lang.UnsatisfiedLinkError: couldn’t find DSO to load: libhermes.so
i did the same thing, alongwith “def enableProguardInReleaseBuilds = false” in the same file, but when i pushed my app bundle to play store it is crashing on startup.
Doesn’t work.
https://github.com/facebook/react-native/issues/27116
I got the same error (couldn’t find DSO to load: libhermes.so) even with hermes disabled and without changing any gradle file apparently. After looking at the logcat I saw the initial error few lines above:
and I guess the hermes error happens because of the fallback. Then after double check my gradle files I found the issue (at least for me)
I had this in my root build.gradle:
where I added jitpack because of a 3rd party library requirement.
After changing to this (separate blocks):
The issue is gone and app doesn’t crash anymore. So it looks like build succeeds but resulting APK doesn’t contain the right ‘jsc’ libraries, probably because download fails in the maven directive (don’t have a real explanation btw).
0.60.4 still face this issue.
OK for me, I had to add jsc to android/build.gradle, because it’ll otherwise try to load hermes by default:
I can’t figure this out. I’ve followed most of the advice and this still crashes even when hermes is disabled. Any idea why? Where exactly is this libhermes.so supposed to be?
I just managed to upgrade my entire project to react native “0.60.5”. I was so fed up trying to change various settings which never worked so I did everything from scratch.
Basically you have to create the new project using
react-native init <ProjectName>
and start installing all the libraries you are using and adding their settings. For example, I used facebook login apk and some of the firebase libraries. I installed 1 by 1 and added their corresponding settings. After tweaking couple of things, everything built up and works fine!By default hermes is disabled and dont even try to enable it 😃
Tried the above configurations many times and the app crashes with the same error no matter what. Its a shame as after upgrading to RN 6 it seemed like everything was up to date, no errors nothing all clean and shiny, all compiled and launched but crashing on startup.
I have tried @gpawlik solution and even pointing to both
hermes-engine
andhermesvm
but the same issue.I kind of want to try and build the new project and start applying my current project settings to see when it crashes, but I rather spend my 12h doing something better …
EDITED: I just tried creating new react native 6+ project with enabled hermes engine or disabled. Both cases worked fine. I copied every single setting, package, upgraded everything to their versions point to point and still getting the same issue. I give up
If like @SourceCipher you’re having issues disabling hermes, check out the solution in this thread to add
url("$rootDir/../node_modules/jsc-android/dist")
Hmmm, it could be happen by magic, but the error went away … now I can at least build a .aab for PlayStore which doesn’t crash. RN is 60.5 … and the only thing I am aware that I’ve changed is in android/build.gradle from 3.4.2 downgrade to 3.4.1:
classpath("com.android.tools.build:gradle:3.4.1")
I assume Android Studio asked me to upgrade it a couple of days ago … but maybe it is just a magic.
did you solve it?
You have to add the following conditional dependencies:
Globals:
In Android Section:
In Dependencies Section
For me Hermes is not working I dont know why? My app size is that much as it was before enabling Hermes
@sriraman I wish I had documented exactly the steps I took to solve this issue, because it took a couple days of banging my head against the wall to get it. The best advice I can give you in absence of what I did step by step is the follow the upgrade helper and to look at all threads on StackOverflow in addition to GH pertaining to this issue. There were a lot of useful solutions specifically here and here
@ebwinters read the theme, we solved our problems
Same here. What u did to fix it?
@yjkimjunior @vijayhfs that’s a different issue with
libjsc
, nothing to do with this Hermes issue.The solution is in these two comments: https://github.com/facebook/react-native/issues/25601#issuecomment-510850228 https://github.com/facebook/react-native/issues/25601#issuecomment-510856047
The important thing is that upgrading React Native is not (usually) simply a case of updating the version number in
package.json
. Use https://react-native-community.github.io/upgrade-helper/ to see which files need to be modified between two versions, or use thereact-native upgrade
command.