React Native Firebase Crashlitics:找不到 DSO libhermes.so。

5
我刚刚设置了Firebase Crashlitics并看到了这个错误:
致命异常: java.lang.UnsatisfiedLinkError 找不到要加载的DSO: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
从我的研究来看,这个错误是由于某些不支持Hermes的设备引起的:https://github.com/facebook/react-native/issues/29528 通常会提出几种解决方案: 解决方案1:android/app/build.gradle中添加:
implementation 'com.facebook.soloader:soloader:0.9.0+'

解决方案 2. 添加:

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
}

解决方案3:添加:

def enableSeparateBuildPerCPUArchitecture = true

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

这些提案来自不同的时期。 在我的手机上没有遇到过这个崩溃(它可以在Crashlitics上找到),我不知道应该选择哪个解决方案。


嗨,Gaylord,我遇到了同样的问题。你能想出解决方案吗?我真的很感激你的帮助。 - Md. Robi Ullah
2个回答

3

选项1:

如果您使用的是v0.64.2或更高版本的react-native,则我认为这不是必需的,因为它已经包含了soloader

选项2:

如果您正在使用react-native-config或者一般自定义的buildTypes,例如:

    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"
      }
}

在这个示例中,我们添加了不默认存在的staging构建类型。在这种情况下,我们需要通过以下方式将Hermes包含在暂存构建类型中:
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
}

同时,还需添加以下行以从暂存构建中排除调试器。
project.ext.react = [
    enableHermes: true,  // clean and rebuild if changing
    
    devDisabledInStaging: true, // Added
    bundleInStaging: true, // Added
]

1

我可以通过添加solution1implementation 'com.facebook.soloader:soloader:0.9.0+')来解决这个奇怪的问题。

但是最近这已经没有用了,而这个解决方法解决了它(react-native-0.63.4)。

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 {
       ...
    }
    ...

}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接