Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android crashes when booting on 0.68.0-rc.2 when hermes enabled #33412

Closed
RalissonMattias opened this issue Mar 11, 2022 · 10 comments
Closed

Android crashes when booting on 0.68.0-rc.2 when hermes enabled #33412

RalissonMattias opened this issue Mar 11, 2022 · 10 comments
Labels
Needs: Triage 🔍 Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@RalissonMattias
Copy link

Description

When updating to the new version the app crashes on start. I have hermes enabled.
I get the following log

2022-03-11 10:47:27.653 24788-24788/com.jurishand.app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.jurishand.app, PID: 24788
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found result: 0
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:1098)
        at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:914)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:826)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:773)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:743)
        at com.facebook.react.jscexecutor.JSCExecutor.loadLibrary(JSCExecutor.java:24)
        at com.facebook.react.jscexecutor.JSCExecutor.<clinit>(JSCExecutor.java:20)
        at com.facebook.react.jscexecutor.JSCExecutor.loadLibrary(JSCExecutor.java:24)
        at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:351)
        at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:318)
        at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:95)
        at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:42)
        at com.jurishand.app.MainApplication.onCreate(MainApplication.java:71)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1182)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460)
        at android.app.ActivityThread.access$1300(ActivityThread.java:219)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: library "libjsc.so" not found
        at java.lang.Runtime.load0(Runtime.java:938)
        at java.lang.System.load(System.java:1631)
        at com.facebook.soloader.SoLoader$1.load(SoLoader.java:529)
        at com.facebook.soloader.DirectorySoSource.loadLibraryFrom(DirectorySoSource.java:110)
        at com.facebook.soloader.DirectorySoSource.loadLibrary(DirectorySoSource.java:63)
        at com.facebook.soloader.ApplicationSoSource.loadLibrary(ApplicationSoSource.java:91)
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:1038)


I tried a solution that worked and the app works correctly

in android/build.gradle add

maven {
  url("$rootDir/../node_modules/jsc-android/dist")
}

in android/app/build.gradle add

if (useIntlJsc) {
   implementation 'org.webkit:android-jsc-intl:+'
} else {
   implementation 'org.webkit:android-jsc:+'
}   

however the const isHermes = () => !!global.HermesInternal; returns false

Version

0.68.0-rc.2

Output of npx react-native info

System:
OS: Windows 10 10.0.22000
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 1.89 GB / 15.73 GB
Binaries:
Node: 16.13.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.1.0 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 23, 28, 29, 30, 31
Build Tools: 28.0.2, 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0
System Images: android-28 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Version 2021.1.0.0 AI-211.7628.21.2111.8092744
Visual Studio: Not Found
Languages:
Java: 11.0.12
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.68.0-rc.2 => 0.68.0-rc.2
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Update RN from 0.66.4 to 0.68.0-rc.2

Snack, code example, screenshot, or link to a repository

No response

@react-native-bot react-native-bot added the Platform: Android Android applications. label Mar 11, 2022
@RalissonMattias RalissonMattias changed the title Android crashes when booting on 0.68.0-rc.2 Android crashes when booting on 0.68.0-rc.2 when hermes enabled Mar 11, 2022
@RalissonMattias
Copy link
Author

@cortinico
Copy link
Contributor

Are you running on a custom flavor/build-type?

@RalissonMattias
Copy link
Author

RalissonMattias commented Mar 12, 2022

Look how is my buildTypes

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            resValue "string", "CodePushDeploymentKey", '"key"'
            if (nativeArchitectures) {
                ndk {
                    abiFilters nativeArchitectures.split(',')
                }
            }
        }
        releaseStaging {
            resValue "string", "CodePushDeploymentKey", '"key"'

            // Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
            // Add the following line if not already there
            matchingFallbacks = ['release']
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://facebook.github.io/react-native/docs/signed-apk-android.
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            resValue "string", "CodePushDeploymentKey", '"key"'
        }
    }

@cortinico
Copy link
Contributor

Could you (or someone else) create a reproducer using the default template for Android and your configuration + verify that it also crashes? That would be a good starting point to find a fix

@RalissonMattias
Copy link
Author

@cortinico ok i will do it

@RalissonMattias
Copy link
Author

RalissonMattias commented Mar 12, 2022

@cortinico I changed my buildTypes in a default project with my current project settings, the app doesn't break. But when I put all the build.gradle in the default project the app crashes

@RalissonMattias
Copy link
Author

I will do more tests and compare the two versions

@RalissonMattias
Copy link
Author

@cortinico I found the problem

This code snippet was at the top of my file

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

Doing this on my android/app/build.gradle resolves my problem

project.ext.react = [
    entryFile: "index.js",
    enableHermes: true,  // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"

@cortinico
Copy link
Contributor

Awesome 👍

@zhuzheng1991
Copy link

zhuzheng1991 commented Nov 1, 2022

i fix this. you can override getJavaScriptExecutorFactory in your ReactNativeHost if you use hermes,force JSExecutorFactory use hermesExecutorFactory

override fun getJavaScriptExecutorFactory(): JavaScriptExecutorFactory? {
        HermesExecutor.loadLibrary()
        return HermesExecutorFactory()
}

@facebook facebook locked as resolved and limited conversation to collaborators Mar 16, 2023
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants