我刚刚设置了Firebase Crashlitics,我看到了这个错误:
致命例外: java.lang.UnsatisfiedLinkError无法找到要加载的DSO : libhermes.so SoSource 0: com.facebook.soloader.ApkSoSourceroot =/data/data/com.walolofit/ lib -主标志=1 SoSource 1: com.facebook.soloader.DirectorySoSourceroot = SoSource标志=0 SoSource 2: com.facebook.soloader.DirectorySoSourceroot =/供应商/lib 64标志=2 SoSource 3: com.facebook.soloader.DirectorySoSourceroot =/system/lib 64标志=2个本机lib dir:/data/app/~~DAa5QmzRi5oxpzp3KsccGQ==/com.wololofit-EEiD-rJZDFCbRjzPj4o-mQ==/lib/arm64结果: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上找到的),我不知道该选择哪种解决方案。
发布于 2022-01-26 00:21:49
选项1.
如果您使用的是react本机v0.64.2或更高版本,我不认为这是强制性的,因为它已经包括了soloader。
选项2.
如果您正在使用react本机-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
]发布于 2022-01-25 08:19:54
我总是可以通过添加solution1 (即implementation 'com.facebook.soloader:soloader:0.9.0+' )来解决这个问题。
但是最近它没有起作用,而这个解决方法解决了它(react本机-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 {
...
}
...
}https://stackoverflow.com/questions/70734154
复制相似问题