facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.55k stars 24.28k forks source link

[0.60.3] App crash on startup when enabling Hermes (enableHermes: true) #25601

Closed bhaskarGyan closed 5 years ago

bhaskarGyan commented 5 years ago

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

Steps To Reproduce

  1. Follow the steps mentioned in hermes
  2. 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

Karniej commented 5 years ago

The same thing is happening to me, the build is successful, but:

  1. The metro bundler doesn't start up
  2. I have this error 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)
benoitdion commented 5 years ago

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?

mjmasn commented 5 years ago

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)
dov11 commented 5 years ago

In my case I saw this crash when:

  1. I first build release with enableHermes: false
  2. Change enableHermes: true
  3. 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

Villar74 commented 5 years ago

@dov11 cleaning build doesn't help with that for me P.S. I want to use hermes, so i set it to true

qadratic commented 5 years ago

I, following the guide set enableHermes to true but cant see any global variable named HermesInternal.

AbanoubNassem commented 5 years ago

same issue here it builds fine but crashes on start up

Jalson1982 commented 5 years ago

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

Kennytian commented 5 years ago

couldn't find DSO to load: libhermes.so

--------- 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
vodanh109 commented 5 years ago

Same issues

bhaskarGyan commented 5 years ago
  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

chubillkelvin commented 5 years ago

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.

rafaumlemos commented 5 years ago

Same issue here.

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so

vijayhfs commented 5 years ago

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.

mjmasn commented 5 years ago

@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.

bhaskarGyan commented 5 years ago

The solution is in these two comments: #25601 (comment)

@mjmasn I am getting below error using above solution

Error :

bradbyte commented 5 years ago

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!

bhaskarGyan commented 5 years ago

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

vodanh109 commented 5 years ago

@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

bhaskarGyan commented 5 years ago

@vodanh109 , is it even after ./gradlew clean?

can you share sample project github url?

vodanh109 commented 5 years ago

@bhaskarGyan yeap, even after ./gradlew clean, still crashed after starting up. I just use the initial project, no more change

vodanh109 commented 5 years ago

I think I passed this issue, via ./gradlew clean, but now I have problem same as #25599 when run with --variant release

rafaumlemos commented 5 years ago

@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

Same here. What u did to fix it?

YajanaRao commented 5 years ago

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''
Karniej commented 5 years ago

@benoitdion Thanks , this one helped me :)

vijayhfs commented 5 years ago

@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 :)

retyui commented 5 years ago

@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!

// mobile/android/app/build.gradle
project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing
]
Karniej commented 5 years ago

@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 image

to apply from: "./react.gradle"

Karniej commented 5 years ago

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

ebwinters commented 5 years ago

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:


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

/**
 * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
 * and bundleReleaseJsAndAssets).
 * These basically call `react-native bundle` with the correct arguments during the Android build
 * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
 * bundle directly from the development server. Below you can see all the possible configurations
 * and their defaults. If you decide to add a configuration block, make sure to add it before the
 * `apply from: "../../node_modules/react-native/react.gradle"` line.
 *
 * project.ext.react = [
 *   // the name of the generated asset file containing your JS bundle
 *   bundleAssetName: "index.android.bundle",
 *
 *   // the entry file for bundle generation
 *   entryFile: "index.android.js",
 *
 *   // whether to bundle JS and assets in debug mode
 *   bundleInDebug: false,
 *
 *   // whether to bundle JS and assets in release mode
 *   bundleInRelease: true,
 *
 *   // whether to bundle JS and assets in another build variant (if configured).
 *   // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
 *   // The configuration property can be in the following formats
 *   //         'bundleIn${productFlavor}${buildType}'
 *   //         'bundleIn${buildType}'
 *   // bundleInFreeDebug: true,
 *   // bundleInPaidRelease: true,
 *   // bundleInBeta: true,
 *
 *   // whether to disable dev mode in custom build variants (by default only disabled in release)
 *   // for example: to disable dev mode in the staging build type (if configured)
 *   devDisabledInStaging: true,
 *   // The configuration property can be in the following formats
 *   //         'devDisabledIn${productFlavor}${buildType}'
 *   //         'devDisabledIn${buildType}'
 *
 *   // the root of your project, i.e. where "package.json" lives
 *   root: "../../",
 *
 *   // where to put the JS bundle asset in debug mode
 *   jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
 *
 *   // where to put the JS bundle asset in release mode
 *   jsBundleDirRelease: "$buildDir/intermediates/assets/release",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in debug mode
 *   resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
 *
 *   // where to put drawable resources / React Native assets, e.g. the ones you use via
 *   // require('./image.png')), in release mode
 *   resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
 *
 *   // by default the gradle tasks are skipped if none of the JS files or assets change; this means
 *   // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
 *   // date; if you have any other folders that you want to ignore for performance reasons (gradle
 *   // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
 *   // for example, you might want to remove it from here.
 *   inputExcludes: ["android/**", "ios/**"],
 *
 *   // override which node gets called and with what additional arguments
 *   nodeExecutableAndArgs: ["node"],
 *
 *   // supply additional arguments to the packager
 *   extraPackagerArgs: []
 * ]
 */

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,
]

apply from: "../../node_modules/react-native/react.gradle"

/**
 * Set this to true to create two separate APKs instead of one:
 *   - An APK that only works on ARM devices
 *   - An APK that only works on x86 devices
 * The advantage is the size of the APK is reduced by about 4MB.
 * Upload all the APKs to the Play Store and people will download
 * the correct one based on the CPU architecture of their device.
 */
def enableSeparateBuildPerCPUArchitecture = false
def enableHermes = project.ext.react.get("enableHermes", false);

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */
def enableProguardInReleaseBuilds = false

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

maamounapprise commented 5 years ago

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

Villar74 commented 5 years ago

@ebwinters read the theme, we solved our problems

retyui commented 5 years ago

@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()
RodneyOnyi commented 5 years ago

Don't forget to add def jscFlavor = 'org.webkit:android-jsc:+'

ebwinters commented 5 years ago

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.

rafaumlemos commented 5 years ago

@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 =)

DFearing commented 5 years ago

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?

rozPierog commented 5 years ago

Can somebody open up this issue. There are still lots of us with this problem? Cc: @bhaskarGyan

hend-elsahli commented 5 years ago

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

sriraman commented 5 years ago

Tried all the solutions listed, still facing the same issue :( Suggest solutions if anyone find any leads..

ebwinters commented 5 years ago

@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

affanhashone commented 5 years ago

Guys Still the App Crashes On New Installation in release mode, when hermes is enable

HarshitMadhav commented 5 years ago

For me Hermes is not working I dont know why? My app size is that much as it was before enabling Hermes

affanhashone commented 5 years ago

@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);

HarshitMadhav commented 5 years ago

yes I have enabled Hermes by this def enableHermes = project.ext.react.get("enableHermes", true);

affanhashone commented 5 years ago

@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" ]

HarshitMadhav commented 5 years ago

No, I havent changed this one yet. Will I have to add hermesCommand also?

mgenov commented 5 years ago

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
    }
HarshitMadhav commented 5 years ago

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

affanhashone commented 5 years ago

@HarshitMadhav But install the libary hermes-engine in dev depencies

please follow this : https://react-native-community.github.io/upgrade-helper/