react-native: Hermes emit binary crash
When running with --variant release
or doing a production build, the Hermes emit binary step fails, leaving a 0 byte bundle file. It looks like something to do with overwriting the same file, as if I cancel the build before the hermes step, then manually run the command from the Program arguments below but with a different output path, it works fine and the bytecode bundle is saved correctly.
Stack dump:
0. Program arguments: ../../node_modules/hermesvm/linux64-bin/hermes -emit-binary -out /REDACTED/android/app/build/generated/assets/react/release/index.android.bundle /REDACTED/android/app/build/generated/assets/react/release/index.android.bundle -O -output-source-map
1. Program arguments: ../../node_modules/hermesvm/linux64-bin/hermes -emit-binary -out /REDACTED/android/app/build/generated/assets/react/release/index.android.bundle /REDACTED/android/app/build/generated/assets/react/release/index.android.bundle -O -output-source-map
[0x41ba83]
[0x41abc9]
[0x41ac6c]
[0x4265e0]
[0x499f43]
[0x49a163]
[0x43d7ff]
[0x43d967]
[0x44003a]
[0x4399b2]
[0x439b32]
[0x42b8b9]
[0x4308d6]
[0x40487b]
[0x712f34]
[0x7131b1]
[0x408116]
[0x41ba83]
[0x41abc9]
[0x41ac6c]
[0x4265e0]
[0x499f43]
[0x49a163]
[0x43d7ff]
[0x43d967]
[0x44003a]
[0x4399b2]
[0x439b32]
[0x42b8b9]
[0x4308d6]
[0x40487b]
[0x712f34]
[0x7131b1]
[0x408116]
FAILURE: Build failed with an exception.
* Where:
Script '/REDACTED/android/app/react.gradle' line: 150
* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command '../../node_modules/hermesvm/linux64-bin/hermes'' finished with non-zero exit value 135
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 57s
React Native version:
System:
OS: Linux 4.15 Ubuntu 16.04.6 LTS (Xenial Xerus)
CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
Memory: 2.09 GB / 15.54 GB
Shell: 4.3.48 - /bin/bash
Binaries:
Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
Yarn: 1.16.0 - /usr/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
Android SDK:
API Levels: 22, 24, 26, 27, 28, 29
Build Tools: 23.0.1, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.3, 28.0.2, 28.0.3, 29.0.0
System Images: android-22 | Google APIs Intel x86 Atom_64, android-24 | Google APIs ARM 64 v8a, android-24 | Google APIs Intel x86 Atom, android-24 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-25 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64
Android NDK: 17.1.4828580
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
npmPackages:
react: 16.8.6 => 16.8.6
react-native: ^0.60.3 => 0.60.3
npmGlobalPackages:
create-react-native-app: 2.0.2
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7
Steps To Reproduce
- Try creating a Hermes-enabled release build
- đ„
Describe what you expected to happen: The build to succeed.
Snack, code example, or link to a repository: Any new RN 0.60.3 app, but I made an example at https://github.com/mjmasn/HermesApp
- Clone the repo
- Run yarn
- Run
yarn start
- In a second terminal window run
react-native run-android --variant release
- Build fails
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 28
- Comments: 45 (7 by maintainers)
@valery-lavrik see my earlier comments https://github.com/facebook/react-native/issues/25601#issuecomment-510856047
NB this was a quick temporary workaround so I could test out Hermes, the RN / Hermes team need to fix this properly.
node_modules/react-native
toandroid/app
commandLine(getHermesCommand(),...
with:Below this (outside the exec section around
commandLine(getHermesCommand(),...
) add this:@B4UGUYS see the last code snippet on this https://github.com/facebook/react-native/issues/25601#issuecomment-510856047
Youâll need to copy react.gradle from node_modules to your android/app folder before editing it.
Replace the line starting
commandLine(getHermesCommand()
with my snippet.I think this issue is still on react native version 0.60.5 .
@zeljkoX @vitalyiegorov I am seeing the same issue as you, I use circleci. I have tried various ways to reduce java heap size and such and it doesnât seem to be related to that. The only difference I can see for me is that locally I run on mac OS and in circleci I use the an android-node docker image. I assume that means that locally it uses ânode_modules/hermesvm/osx-bin/hermesâ whereas on circleci uses ânode_modules/hermesvm/linux64-bin/hermesâ so Iâm guesssing the issue is related to that. Was wondering whether you guys are also building on mac locally?
This should be fixed in https://github.com/facebook/hermes/issues/45 and will be included in 0.61
Same error building with gitlab-ci, locally works perfectly, rn 0.60.5
For me, everything works locally but executing it on CI results in a reported error. Maybe memory issues with CI.
Can Hermes memory usage, number of daemons/threads, can be limited?
@LydGol90 Also, using mac locally, docker image for android on CircleCI.
I am still having this problem with
0.60.5
@zeljkoX same thing happens to me. Runs fine locally but crashes running on CircleCI. Did you find a fix?
@valery-lavrik this is because the commit youâve linked is available in the latest master, but is not yet available in the stable releases.
A new release containing this fix should be available soon enough.
@mjmasn
I copied the react.gradle file and made changes to it: and but command .\gradlew clean and .\gradlew --info bundleRelease still return an error: why?
@reactjs-bot @react-native-bot @mjmasn i have followed the above steps but I get an error like this
Process âcommand ââŠ\node_modules\hermesvm\win64-bin\hermesââ finished with non-zero exit value -1073741515 Please post some solution for this.Below I posted my react.gradle file
` if (enableHermes) { doLast { def hermesFlags; exec { // if (targetName.toLowerCase().contains(âreleaseâ)) { 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 = [] } commandLine(getHermesCommand(), â-emit-binaryâ, â-outâ, jsBundleFile, jsBundleFile, *hermesFlags) } if (hermesFlags.contains(â-output-source-mapâ)) { ant.move( // Hermes will generate a source map with this exact name // NOTE: name coincides with jsOutputSourceMapFile file: â${jsBundleFile}.mapâ, tofile: jsCompilerSourceMapFile ); exec { // TODO: set task dependencies for caching
`
If youâre building your android app using RN 0.60. x on CircleCI and Linux, you can set
enableHermes: false
inandroid/app/build.gradle:80
to disable the Hermes JS engine and prevent this error until the issue is patched by FB.@aecorredor I havenât.
@adnkh Exactly the same thing happened to me. I uploaded APKs instead and the problem was fixed.
I have a similar error: without text âfinished with non-zero exit valueâ
what should I do?
@LuckyLuke19 you should move it outside
exec
. Have the same issue and got it work by moving it outside.Thank you @mjmasn I was having the same issue, your snipped did the trick!