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(R) Core(TM) 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
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
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)
you'll need to add
def enableHermes = project.ext.react.get("enableHermes", false);
at the top of your build.gradle
file and
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
in your dependencies.
Should we move those bits of configuration to react.gradle
?
If you have additional build types those will need to be added too, e.g.
integrationImplementation files(hermesPath + "hermes-release.aar")
stagingImplementation files(hermesPath + "hermes-release.aar")
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")
.
if (!targetName.toLowerCase().contains("debug")) {
// Can't use ?: since that will also substitute valid empty lists
hermesFlags = config.hermesFlagsRelease
if (hermesFlags == null) hermesFlags = ["-O", "-output-source-map"]
} else {
hermesFlags = config.hermesFlagsDebug
if (hermesFlags == null) hermesFlags = []
}
and
// Delete the VM related libraries that this build doesn't need.
// The application can manage this manually by setting 'enableVmCleanup: false'
//
// This should really be done by packaging all Hermes releated libs into
// two separate HermesDebug and HermesRelease AARs, but until then we'll
// kludge it by deleting the .so files out of the /transforms/ directory.
def isRelease = !targetName.toLowerCase().contains("debug")
Also added a quick fix for #25609
ant.move(
file: jsBundleFile,
tofile: "${jsBundleFile}_temp"
);
commandLine(getHermesCommand(), "-emit-binary", "-out", jsBundleFile, "${jsBundleFile}_temp", *hermesFlags)
In my case I saw this crash when:
enableHermes: false
enableHermes: true
all while
def enableHermes = project.ext.react.get("enableHermes", false);
and
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
were present.
Crash disappears after cleaning the build:
cd android && ./gradlew clean
@dov11 cleaning build doesn't help with that for me
P.S. I want to use hermes, so i set it to true
I, following the guide set enableHermes to true but cant see any global variable named HermesInternal.
same issue here it builds fine but crashes on start up
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
--------- beginning of crash
2019-07-14 09:44:01.739 11565-12396/com.rn0602 E/AndroidRuntime: FATAL EXCEPTION: create_react_context
Process: com.rn0602, PID: 11565
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)
2019-07-14 09:44:01.914 2015-2015/? E/Layer: [Surface(name=AppWindowToken{5d867f6 token=Token{70d7c91 ActivityRecord{8ebe6b8 u0 com.rn0602/.MainActivity t22}}})/@0x7826de8 - animation-leash#0] No local sync point found
2019-07-14 09:44:01.914 2015-2015/? E/Layer: [Surface(name=AppWindowToken{683f3c9 token=Token{99157d0 ActivityRecord{3bb3b93 u0 com.google.android.apps.nexuslauncher/.NexusLauncherActivity t5}}})/@0x69d81a9 - animation-leash#0] No local sync point found
2019-07-14 09:44:12.219 2249-2281/system_process E/memtrack: Couldn't load memtrack module
2019-07-14 09:44:12.224 2249-2281/system_process E/memtrack: Couldn't load memtrack module
2019-07-14 09:44:12.230 2249-2281/system_process E/memtrack: Couldn't load memtrack module
2019-07-14 09:44:23.112 2154-2154/? E/netmgr: Failed to open QEMU pipe 'qemud:network': Invalid argument
2019-07-14 09:44:23.113 2154-2154/? E/netmgr: WifiForwarder unable to open QEMU pipe: Invalid argument
2019-07-14 09:44:38.328 2249-2281/system_process E/memtrack: Couldn't load memtrack module
Same issues
if (enableHermes) { def hermesPath = "../../node_modules/hermesvm/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { // @benoitdion where are we initialising the variable jscFlavor? implementation jscFlavor }
in your dependencies.
Should we move those bits of configuration to
react.gradle
?
@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
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 here.
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
this worked for me: https://stackoverflow.com/questions/56734877/getting-library-libjsc-so-not-found-after-upgrading-react-native-to-0-60-rc2
I am also facing the the same issue. Can you please explain this in details if this worked for you to resolve Hermes issue.
@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 the react-native upgrade
command.
The solution is in these two comments:
#25601 (comment)
@mjmasn I am getting below error using above solution
Error :
Could not resolve all files for configuration ':app:releaseCompileClasspath'.
Failed to transform file 'hermes-release.aar' to match attributes {artifactType=android-manifest}
Execution failed for JetifyTransform: /Users/../node_modules/hermesvm/android/hermes-release.aar.
Failed to transform '/Users/.../reactNativeMemoryProfile/node_modules/hermesvm/android/hermes-release.aar' using Jetifier. Reason: Cannot open a library at 'FileMapping(from=/Users/.../reactNativeMemoryProfile/node_modules/hermesvm/android/hermes-release.aar, to=/Users/.../.gradle/caches/transforms-2/files-2.1/1f2be632de94c0fe0ca58b3163f651c8/jetified-hermes-release.aar)'.
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!
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
@vodanh109 , is it even after ./gradlew clean?
can you share sample project github url?
@bhaskarGyan yeap, even after ./gradlew clean, still crashed after starting up. I just use the initial project, no more change
I think I passed this issue, via ./gradlew clean, but now I have problem same as #25599 when run with --variant release
@bhaskarGyan
I init project from react native cli, with version 0.60.3, and still meet the problem withcouldn't find DSO to load: libhermes.so
Any clue for that?
Thanks
Same here.
What u did to fix it?
I do have the same issue
Error: Command failed: gradlew.bat app:installRelease -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> A problem occurred starting process 'command '..\..\node_modules\hermesvm\win64-bin\hermes''
@benoitdion Thanks , this one helped me :)
@Karniej after that you have Hermes off, or i mistake?
The only thing that help me to get Hermes work is to init new app with the same name and carefully move my project to a new one.
Exactly. I also init a new app which helped me :)
@mjmasn After update to the latest version [email protected]
I have got this error when I run my app
And in my project I do not enable Hermes!
// mobile/android/app/build.gradle
project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]
@Villar74 I actually just started a new project with a v.060 so the move to .60.3 was quite easy in the end. I had to use @mjmasn tip of copying react.gradle and changing this line in android/app/build.gradle
to apply from: "./react.gradle"
Then remember to have mirrored
this section:
project.ext.react = [
entryFile: "index.js",
enableHermes: true
]
and this one
def enableHermes = project.ext.react.get("enableHermes", true);
Both have to have the same value (true/false) in order to enable/disable Hermes
I am getting this error:
E/SoLoader: couldn't find DSO to load: libhermes.so
E/AndroidRuntime: FATAL EXCEPTION: create_react_context
With android/build.gradle:
```// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "11.8.0"
}
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter {
url "http://jcenter.bintray.com/"
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
google()
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
and app/build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
react-native bundle
with the correct arguments during the Android buildapply from: "../../node_modules/react-native/react.gradle"
line.project.ext.react = [
entryFile: "index.js",
enableHermes: false,
]
apply from: "../../node_modules/react-native/react.gradle"
/**
/**
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.goumd"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 9
versionName "2.4"
ndk {
abiFilters "armeabi-v7a", "x86", "x86_64"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
configurations.all {exclude group: 'com.android.support', module: 'support-v4'}
dependencies {
implementation project(':@react-native-community_netinfo')
implementation project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
```
Any help is greatly appreciated
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
@ebwinters read the theme, we solved our problems
@ebwinters
I think you should edit the next code:
mavenLocal()
jcenter {
url "http://jcenter.bintray.com/"
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
to this:
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
jcenter {
url "http://jcenter.bintray.com/"
}
mavenLocal()
Don't forget to add
def jscFlavor = 'org.webkit:android-jsc:+'
Problem was solved by reading https://github.com/react-native-community/rn-diff-purge/compare/release/0.59.10..release/0.60.3 (which was essentially doing above 2 comments)
If anyone else is facing this issue, you can also try Refactor -> Migrate to AndroidX
. This fixed a lot of issues for me.
@ebwinters
I think you should edit the next code:mavenLocal() jcenter { url "http://jcenter.bintray.com/" } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" }
to this:
maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android" } jcenter { url "http://jcenter.bintray.com/" } mavenLocal()
Thanks for helping bro. I've resolved my issue too.
You saved my life. Thanks a lot =)
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:
Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName + 738(SoLoader.java:738)
at com.facebook.soloader.SoLoader.loadLibraryBySoName + 591(SoLoader.java:591)
at com.facebook.soloader.SoLoader.loadLibrary + 529(SoLoader.java:529)
at com.facebook.soloader.SoLoader.loadLibrary + 484(SoLoader.java:484)
at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit> + 20(HermesExecutor.java:20)
at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create + 27(HermesExecutorFactory.java:27)
at com.facebook.react.ReactInstanceManager$5.run + 949(ReactInstanceManager.java:949)
at java.lang.Thread.run + 818(Thread.java:818)
Any thoughts?
Can somebody open up this issue. There are still lots of us with this problem? Cc: @bhaskarGyan
Same issue here ... the app is working perfectly with hermes enables in debug-mode ... but in release mode it crashes silently in components with FlatList
Tried all the solutions listed, still facing the same issue :( Suggest solutions if anyone find any leads..
@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
Guys Still the App Crashes On New Installation in release mode, when hermes is enable
For me Hermes is not working I dont know why? My app size is that much as it was before enabling Hermes
@HarshitMadhav have you Enable the hermes in build.gradle file
project.ext.react = [
entryFile: "index.js",
enableHermes: true, // clean and rebuild if changing
hermesCommand: "../node_modules/hermes-engine/%OS-BIN%/hermes"
]
def enableHermes = project.ext.react.get("enableHermes", true);
yes I have enabled Hermes by this def enableHermes = project.ext.react.get("enableHermes", true);
@HarshitMadhav
how about this ?
project.ext.react = [
entryFile: "index.js",
enableHermes: true, // clean and rebuild if changing
hermesCommand: "../node_modules/hermes-engine/%OS-BIN%/hermes"
]
No, I havent changed this one yet. Will I have to add hermesCommand also?
You have to add the following conditional dependencies:
Globals:
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);
In Android Section:
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
In Dependencies Section
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
Thanks but I have added everything as you have mentioned but the only thing that I was missing is this
project.ext.react = [
entryFile: "index.js",
enableHermes: true, // clean and rebuild if changing
hermesCommand: "../node_modules/hermes-engine/%OS-BIN%/hermes"
]
as it was pointed out by @affanhashone
@HarshitMadhav But install the libary hermes-engine in dev depencies
please follow this : https://react-native-community.github.io/upgrade-helper/
@affanhashone but I am using react-native init and I am already using the latest version 0.60.4 for react native. I haven't upgraded react-native version as I am already on latest version of react-native
@HarshitMadhav yup, still the build will fail. with latest version till they launch the new version of hermes react native. work around is : to installl a herme-engine as dev dependency, and add hermesCommand: "../node_modules/hermes-engine/%OS-BIN%/hermes" to project.ext.react array
also modify the react.gradle in android folder from the master branch.
@affanhashone yes you are right my build failed actually. You mean I will have to install Hermes engine as devdependency from this https://www.npmjs.com/package/hermes-engine? and then add hermesCommand?
@HarshitMadhav Yes but install 0.1.0 version not 0.1.1(though you can try
@affanhashone I dont know why but I added it as simple dependency instead of devdependency my build is successful and app size is also reduced by more then 9 mb.
@affanhashone I tried this new build but its crashing saying com.facebook.jni.CppException: Wrong bytecode version. Expected 59 but got 60
https://github.com/facebook/react-native/issues/25572 go through this
gone through it but didnt helped me. I am trying after adding hermes engine as dev dependency.
https://gist.github.com/zenz/efd1f68ee4099abf77550ac7984df2fd try to update with this react.gradle
No, it didnt work either adding it as dev devpendency. Thank you for the help and staying with me. I think I should wait before actually implementing hermes engine.
replace yours with this : https://github.com/facebook/react-native/blob/master/react.gradle
okay wait I am trying this new solution of yours.
@HarshitMadhav Did you Fix it ?
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")
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
}
enableHermes: false
to enableHermes: true
I 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.
@affanhashone no it didnt worked! Got the error cannnot process cant find path for it
@HarshitMadhav paste your code here
@affanhashone did the same
project.ext.react = [
entryFile: "index.js",
enableHermes: true, // clean and rebuild if changing
hermesCommand: "../node_modules/hermes-engine/%OS-BIN%/hermes"
]
def enableHermes = project.ext.react.get("enableHermes", true);
and also ran clean and rebuild commands and then I generated release apk but it failed with cannot find path in both case adding hermes as dev dependency
and adding as a dependency
.
I, following the guide set enableHermes to true but cant see any global variable named HermesInternal.
did you solve it?
My working solution (using RN 0.60.4
)
build.gradle
, changeapply from: "../../node_modules/react-native/react.gradle"
to
apply from: "./react.gradle"
and
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
to
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/"; // <-- change this
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
hermes-engine
(0.1.1)yarn add -D hermes-engine
react-native run-android --variant release
@HarshitMadhav I got the same error as you were
com.facebook.jni.CppException: Wrong bytecode version. Expected 59 but got 60
In your case, I think you should check step 2 to change hermesPath
@r0b0t3d Thanks ! I will try it and let you know.
@r0b0t3d I tried your method. My app builds normally right now, but when it encounters any screen with a FlatList component, my app crashes automatically.
The error is still
2019-08-07 14:33:11.708 29229-29375/? A/libc: /tmp/hermes/hermes/include/hermes/VM/HandleRootOwner.h:413: hermes::vm::PinnedHermesValue *hermes::vm::GCScope::newHandle(hermes::vm::HermesValue): assertion "getHandleCountDbg() < handlesLimit_ && "Too many handles allocated in GCScope"" failed
@RageBill In my project, screens with FlatList are working well. Have not encountered your error.
FYI, I upgraded from 0.59.10 -> 0.60.4
My working solution (using
RN 0.60.4
)
- Copy react.gradle to android > app
I got an error if i'm using the react.gradle react-native repo. I change it to used this one
The error probably because the react.gradle from react-native repo is not set for the windows os.
// Set up the call to the compose-source-maps script
workingDir(reactRoot)
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine("cmd", "/c", *nodeExecutableAndArgs, composeSourceMapsPath, jsPackagerSourceMapFile, jsCompilerSourceMapFile, "-o", jsOutputSourceMapFile)
} else {
commandLine(*nodeExecutableAndArgs, composeSourceMapsPath, jsPackagerSourceMapFile, jsCompilerSourceMapFile, "-o", jsOutputSourceMapFile)
}
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?
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 once couldn'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
@SourceCipher And the issue is CLOSED. Boom.
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.
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")
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
The solution with installing hermes-engine
works, but the issue can also be fixed by adapting the hermesCommand
option to the path where hermesvm
actually got installed.
In my case instead of a default node_modules/react-native/node_modules/hermesvm
it has been installed in node_modules/hermesvm
, so adapting the options in following way was enough:
project.ext.react = [
...some options...
enableHermes: true,
hermesCommand: "../../node_modules/hermesvm/%OS-BIN%/hermes"
]
...
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
...
Thanks @mjmasn for the custom react.gradle to better handle variant builds.
Is there a PR to fix the file to better handle the release -vs- debug build bug related to hermes ?
(in my case, I had a missing debugger file for a non-debug build... stacktrace started like this :
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes-executor-debug.so caused by: dlopen failed: cannot locate symbol "_ZTIN8facebook6hermes8debugger13EventObserverE" referenced by "/data/app/fr.myapp.alpha-1/lib/x86/libhermes-inspector.so"...
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
and hermesvm
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
Using RN 0.60.5 (Ubuntu)-
In debug mode (react-native run-android
) I was getting following error-
AndroidRuntime: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes-executor-debug.so
I was using classpath 'com.android.tools.build:gradle:3.4.2'
in build.gradle and downgrading it to classpath 'com.android.tools.build:gradle:3.4.1'
worked for me.
But it's still failing in release mode react-native run-android --variant=release
with following error-
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command '../../node_modules/hermesvm/linux64-bin/hermes'' finished with non-zero exit value 135
I created a brand new react native project using react-native init <ProjectName>
and then enabled hermes. It worked for debug mode but got failed for release mode with same error as above :cry:
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 :)
Herms is still not working on release variant in react native "0.60.5" on react-native init
project. Debug variant is fine.
If you have additional build types those will need to be added too, e.g.
integrationImplementation files(hermesPath + "hermes-release.aar") stagingImplementation files(hermesPath + "hermes-release.aar")
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")
.if (!targetName.toLowerCase().contains("debug")) { // Can't use ?: since that will also substitute valid empty lists hermesFlags = config.hermesFlagsRelease if (hermesFlags == null) hermesFlags = ["-O", "-output-source-map"] } else { hermesFlags = config.hermesFlagsDebug if (hermesFlags == null) hermesFlags = [] }
and
// Delete the VM related libraries that this build doesn't need. // The application can manage this manually by setting 'enableVmCleanup: false' // // This should really be done by packaging all Hermes releated libs into // two separate HermesDebug and HermesRelease AARs, but until then we'll // kludge it by deleting the .so files out of the /transforms/ directory. def isRelease = !targetName.toLowerCase().contains("debug")
Also added a quick fix for #25609
ant.move( file: jsBundleFile, tofile: "${jsBundleFile}_temp" ); commandLine(getHermesCommand(), "-emit-binary", "-out", jsBundleFile, "${jsBundleFile}_temp", *hermesFlags)
Hi! How does implement
function work with custom buildTypes? I added implementation
for my custom build types e.g: integration (implementIntegration), development (developmentIntegration), but after building, it crashes with error couldn't find DSO to load: libhermes.so
. Otherwise cases like releaseIntegration
or debugIntegration
works fine with hermes. Where is my mistake?
Code
buildTypes {
debug {
minifyEnabled enableProguardInReleaseBuilds
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
applicationIdSuffix ".local"
}
development {
applicationIdSuffix ".dev"
minifyEnabled enableProguardInReleaseBuilds
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
matchingFallbacks = ['release', 'debug']
}
integration{
applicationIdSuffix ".staging"
minifyEnabled enableProguardInReleaseBuilds
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
matchingFallbacks = ['release']
}
release {
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
developmentImplementation files(hermesPath + "hermes-release.aar")
integrationImplementation files(hermesPath + "hermes-release.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
@Devlin556 did you copy react.gradle from node_modules/react-native/react.gradle
to android/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.
I was getting this issue migrating from react-native 0.60.4 to 0.60.5.
I deleted the '.gradle' directory under 'android', and re-synced/rebuilt the project in Android Studio and that did the trick for me.
Our app doesn't work in production build with Hermes but works in developement fine, with and without debugging. I hope guides will come out to explain out to get it faster in developement though.
In any case our production app is around 2 MB smaller though it doesn't work for now. ^^
I had to use a polyfill for the Reflect API as our app uses Redux ORM, which uses the Reflect API on web usually.
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?
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
@SourceCipher What did you figure out with this? Did you ever get it working?
OK for me, I had to add jsc to android/build.gradle, because it'll otherwise try to load hermes by default:
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
@tmaly1980 With that message you quoted, I figured out that the hermes engine wasnt working 馃槅
Did you managed to upgrade to RN 0.6?
@SourceCipher Yes, it works, these are the bits from my app/build.gradle
project.ext.react = [
entryFile: "index.android.js",
enableHermes: false
]
def enableHermes = project.ext.react.get("enableHermes", false);
def jscFlavor = 'org.webkit:android-jsc:+'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
// ... later on ....
dependencies {
// ....
if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
// ....
}
After that, though I ran into red screen issues connecting to 10.0.2.2:8081, which I solved by modifying AndroidManifest.xml:
<application
android:usesCleartextTraffic="true"
....
This bug is still on 0.60.6, 3 versions later.
Still an issue on 0.61.0 aswell.
0.60.4 still face this issue.
1-upgrade react-native to 0.61
2-enable hermes
project.ext.react = [
entryFile: "index.js",
enableHermes: true
]
def enableHermes = project.ext.react.get("enableHermes", true);
3-add in android/app/build.gradle
android {
...
packagingOptions{
exclude '**/libhermes-inspector.so'
exclude '**/libhermes-executor-debug.so'
exclude '**/libjscexecutor.so'
}
...
}
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
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:
dlopen failed: library "libjsc.so" not found
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_:
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
url("https://jitpack.io")
}
where I added jitpack because of a 3rd party library requirement.
After changing to this (separate blocks):
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
maven {
url("https://jitpack.io")
}
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).
Install Hermes Engine.
NPM
In react.gradle there are checks like this:
targetName.toLowerCase().contains("release")
So I've decided to just rename my custom target name from alpha
to alphaRelease
.
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.
This worked for me!
After enabling Hermes in your project, Please update the Hermes path in "android/app/build.gradle" file. You can see the sample code below.
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
After the update of hermesPath, run your application react-native run-android
. Hermes issue has been fixed.
@SourceCipher Yes, it works, these are the bits from my app/build.gradle
project.ext.react = [ entryFile: "index.android.js", enableHermes: false ] def enableHermes = project.ext.react.get("enableHermes", false); def jscFlavor = 'org.webkit:android-jsc:+' def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } // ... later on .... dependencies { // .... if (enableHermes) { def hermesPath = "../../node_modules/hermesvm/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } // .... }
After that, though I ran into red screen issues connecting to 10.0.2.2:8081, which I solved by modifying AndroidManifest.xml:
<application android:usesCleartextTraffic="true" ....
hi I follow yours modifications, but there will be a Error "libjsexecutor.so not found", and add this https://github.com/facebook/react-native/issues/25537#issuecomment-509959166 modification, app works fine
Should be this as of RN 0.60.4
dependencies {
// ....
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
// ....
}
@juicycleff I can confirm that this works with RN 0.61.2
as well.
Thanks @aliozinan !
I'm on RN 0.61.2 and fixed by replacing hermesvm
with hermes-engine
in android/app/build.gradle
, like this:
def hermesPath = "../../node_modules/hermes-engine/android/";
Now everything works properly.
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.
Doesn't work.
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.Doesn't work.
The error you're getting is clearly telling you that a property was being set multiple times in the object definition during the build process.
This issue is about enabling Hermes Engine and building the project successfully by resolving the "DSO not found" error, hence your issue is not related to this one and should be investigated seperately.
So as a result, my solution actually works for the related issue being this one.
Try with 0.60.0 or 0.61.1 versions, apply the solution recommended in the above messages and check if you're able to get a successful build. If you get "DSO not found" error, report here. Finally, remove the reference in your message here to the issue you opened, it's a wrong reference.
In my side the problem was fixed when I run 'Clean project' and then run again.
In my case I saw this crash when:
- I first build release with
enableHermes: false
- Change
enableHermes: true
- Build release
all while
def enableHermes = project.ext.react.get("enableHermes", false);
and
if (enableHermes) { def hermesPath = "../../node_modules/hermesvm/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor }
were present.
Crash disappears after cleaning the build:
cd android && ./gradlew clean
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.
For people with more build types (let's call it anotherDebug):
// In dependencies {}:
debugImplementation files(hermesPath + "hermes-debug.aar")
anotherDebugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
// This is where the build types are specified (in buildTypes {}):
anotherDebug {
initWith buildTypes.debug
matchingFallbacks = ['debug'] // For libs that don't have this build type
// Add stuff that makes anotherDebug necessary for you
}
For anyone having this issue, this may help.
From React native docs:
Note about Android App Bundles
Android app bundles are not yet supported with hermes
That means Hermes is only for .apk
. I was really had a headache because my release .aab
stucks on splash screen 馃ぃ
Hope this help
Update: Hermes is now supported since RN 0.62 and up
@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.
For people with more build types (let's call it anotherDebug):
// In dependencies {}: debugImplementation files(hermesPath + "hermes-debug.aar") anotherDebugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") // This is where the build types are specified (in buildTypes {}): anotherDebug { initWith buildTypes.debug matchingFallbacks = ['debug'] // For libs that don't have this build type // Add stuff that makes anotherDebug necessary for you }
This solved my issue, thank you @nokite .
Most helpful comment
Same issues