Gaylord.P
Gaylord.P

Reputation: 1468

React Native Firebase Crashlitics : couldn't find DSO libhermes.so

I just set up Firebase Crashlitics and I see this error :

Fatal Exception: java.lang.UnsatisfiedLinkError couldn't find DSO to load: libhermes.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/data/com.wololofit/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = /data/app/~~DAa5QmzRi5oxpzp3KsccGQ==/com.wololofit-EEiD-rJZDFCbRjzPj4o-mQ==/lib/arm64 flags = 0] SoSource 2: com.facebook.soloader.DirectorySoSource[root = /vendor/lib64 flags = 2] SoSource 3: com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] Native lib dir: /data/app/~~DAa5QmzRi5oxpzp3KsccGQ==/com.wololofit-EEiD-rJZDFCbRjzPj4o-mQ==/lib/arm64 result: 0

From my research, this error is for some devices that don't support Hermes : https://github.com/facebook/react-native/issues/29528

Several solutions are often proposed :

Solution 1. add to android/app/build.gradle :

implementation 'com.facebook.soloader:soloader:0.9.0+'

Solution 2. add :

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
    qaImplementation files(hermesPath + "hermes-release.aar")
    stageImplementation files(hermesPath + "hermes-release.aar")
    prodImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}

Solution 3. add :

def enableSeparateBuildPerCPUArchitecture = true

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

These proposals date from several different periods. Not having this crash on my phone (it is found on Crashlitics), I don't know which solution to choose.

Upvotes: 7

Views: 5833

Answers (2)

Aleksandar Nikolic
Aleksandar Nikolic

Reputation: 268

Option 1.

I don't think this one is mandatory if you're using react-native v0.64.2 or above since it includes soloader already

Option 2.

This is a needed if you are using react-native-config or in general using using custom buildTypes like for example:

    buildTypes {
      debug {
        signingConfig signingConfigs.debug
      }
      // Added
      staging { 
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        matchingFallbacks = ['release']        
      }
      release {
        signingConfig signingConfigs.release
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
      }
}

In this sample, we added staging build type which is not there by default. In this case, we need to include Hermes in the staging build type by adding it like so:

if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    stagingImplementation files(hermesPath + "hermes-debug.aar") // Added
    releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
    implementation jscFlavor
}

as well as add the following lines to exclude debugger from staging build

project.ext.react = [
    enableHermes: true,  // clean and rebuild if changing
    
    devDisabledInStaging: true, // Added
    bundleInStaging: true, // Added
]

Upvotes: 3

Mohammad
Mohammad

Reputation: 883

I could always fix this wierd issue by adding solution1 which is implementation 'com.facebook.soloader:soloader:0.9.0+'

But recently it didn't help and this workaround fixed it (react-native-0.63.4)

in android/app/build.gradle

android: {
    ...
    packagingOptions {
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
    }
    defaultConfig {
       ...
    }
    ...

}

Upvotes: 1

Related Questions