Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native release app crashes with FATAL EXCEPTION: create_react_context

I create the signings for my release app, put them inside android/app/ and inside android/app/build.gradle do the following:

signingConfigs {
    release {
            keyAlias 'my-key-alias'
            keyPassword 'mypassword'
            storeFile file('mykeystore.keystore')
            storePassword 'mypassword'
        }
}

And inside the buildTypes:

buildTypes {
    release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            firebaseCrashlytics {
                nativeSymbolUploadEnabled true
            }
        }
}

When I run react-native run-android --variant=release the app is installed successfully on my emulator but when I open it, it crashes! I opened the logcats in Android Studio and this is what is printed out:

--------- beginning of crash
2020-08-12 18:53:51.069 5909-5957/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.encarti.mobile.worker, PID: 5909
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:789)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:639)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:577)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:525)
        at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
        at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:29)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:997)
        at java.lang.Thread.run(Thread.java:923)

Something is telling me that it has to do with a library or something. I am using react-native-config for handling my environment variables, I am also using using Firebase so I have a google-services.json inside android/app/. I don't know what else may be causing the error!

Thanks for your answers in advance!

like image 785
davidaap Avatar asked Aug 13 '20 00:08

davidaap


1 Answers

THis is caused by enabling Hermes.

couldn't find DSO to load: libhermes.so

1 - Always clean your gradle build before building your app.

2 - If you use custom builts Variants ex stagingRelease, don't forget to add custom implementation on your /app/build.gradle

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
    stagingReleaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}
like image 74
devoka Avatar answered Nov 22 '22 22:11

devoka