gpt4 book ai didi

android - React native 0.61.5 Crashlytics 缺少 libhermes.so : SoLoader. java com.facebook.soloader.SoLoader.assertInitialized

转载 作者:行者123 更新时间:2023-12-03 13:27:44 27 4
gpt4 key购买 nike

我正在 build 一个 react 原生 应用程序,一切正常,直到我决定从版本 0.59.x 升级到 v 0.61.5 .

当我尝试在 Play 商店中发布我的应用程序时,Firebase Crashlytics 报告了很多崩溃。 ( v 6.2.0 ) -- 尽管我的版本仅可用于内部测试,所以它必须是 pre-launch report由 playstore 触发——对于完全相同的设备,它是完全相同的错误 => LGE Nexus 5X 与 android 6.0.1 .

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
at com.facebook.soloader.SoLoader.assertInitialized(SoLoader.java)
at com.facebook.soloader.SoLoader.assertInitialized(SoLoader.java)
at com.facebook.soloader.SoLoader.assertInitialized(SoLoader.java)
at com.facebook.soloader.SoLoader.assertInitialized(SoLoader.java)
at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java)
at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java)
at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java)
at java.lang.Thread.run(Thread.java:818)

为了解决这个问题,我尝试提交具有稍微不同的android配置的多个版本(例如启用和不启用hermes),但它不会改变最终结果。

这是我的 build.gradle 文件 :
apply plugin: "com.android.application"
apply plugin: "io.fabric"

import com.android.build.OutputFile

/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/

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

apply from: "../../node_modules/react-native/react.gradle"

/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false

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

/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);

def _applicationId = System.getenv("GRADLE_APP_IDENTIFIER") ?: 'com.clothparency.debug'
def appName = System.getenv("GRADLE_APP_NAME") ?: 'Clear Fashion debug'
def _versionCode = (System.getenv("ANDROID_VERSION_CODE") ?: "1") as Integer
def _versionName = System.getenv("ANDROID_VERSION_NAME") ?: "1.0.0"

android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

packagingOptions {
exclude 'META-INF/androidx.exifinterface_exifinterface.version'
}

defaultConfig {
applicationId _applicationId
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode _versionCode
versionName _versionName
missingDimensionStrategy 'react-native-camera', 'mlkit'
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
release {
storeFile file(String.valueOf(System.getenv("GRADLE_KEYSTORE")))
storePassword System.getenv("GRADLE_KEYSTORE_PASSWORD")
keyAlias System.getenv("GRADLE_KEYSTORE_ALIAS")
keyPassword System.getenv("GRADLE_KEYSTORE_ALIAS_PASSWORD")
}
}
buildTypes {
debug {
resValue "string", "app_name", appName
debuggable true
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
release {
resValue "string", "app_name", appName
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}

configurations.all {
resolutionStrategy {
force "com.facebook.soloader:soloader:0.8.1"
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules

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

implementation 'com.android.support:multidex:1.0.3'
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply plugin: 'com.google.gms.google-services'

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

另外,我的根 build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath('com.android.tools.build:gradle:3.5.3')
classpath 'com.google.gms:google-services:4.2.0'

classpath 'io.fabric.tools:gradle:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}

google()
jcenter()
maven { url 'https://jitpack.io' }
}
}

这是我的 的依赖项包.json :
  "dependencies": {
"@react-native-community/async-storage": "^1.6.1",
"@react-native-firebase/analytics": "^6.2.0",
"@react-native-firebase/app": "^6.2.0",
"@react-native-firebase/auth": "^6.2.0",
"@react-native-firebase/crashlytics": "^6.2.0",
"@react-native-firebase/perf": "^6.2.0",
"axios": "^0.18.0",
"fast-levenshtein": "^2.0.6",
"formik": "^1.5.7",
"i18n-js": "^3.2.2",
"jetifier": "^1.6.5",
"lodash": "^4.17.11",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-camera": "^3.13.1",
"react-native-dialog": "^5.6.0",
"react-native-fbsdk": "^1.1.1",
"react-native-formik": "^1.7.5",
"react-native-gesture-handler": "^1.5.2",
"react-native-localize": "^1.1.2",
"react-native-reanimated": "^1.4.0",
"react-native-screens": "^1.0.0-alpha.23",
"react-native-swiper": "^1.6.0-rc.3",
"react-native-tab-view": "^2.11.0",
"react-navigation": "3.13.0",
"react-navigation-tabs": "^2.6.2",
"react-persist": "^1.0.2",
"react-redux": "^7.0.3",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.8",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"unorm": "^1.6.0",
"yup": "^0.27.0"
}

我发现这个 github 问题谈论这个话题:
  • https://github.com/facebook/react-native/issues/25923
  • https://github.com/facebook/hermes/issues/78

  • 但是这里描述的解决方案没有对我有用。

    还在stackoverflow上找到了这个线程: React-Native :java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so :错误似乎与我的略有不同,但解决方案不起作用。

    我害怕将我的新版本发布到生产中,我完全被困住了。需要快速帮助:)

    最佳答案

    我通过生成 apk 解决了这个问题而不是 aab .

    但由于产生了额外的重量,我对这个修复非常不满意,希望它只是一个临时解决方案。

    编辑

    找到了另一个解决方案,我在我的 build.gradle 中添加了这个文件。我不确定副作用,但至少我不再从 crashlytics 中得到这个错误。但似乎我对某些设备仍有问题。

    android {
    defaultConfig {
    // let your old config
    ndk {
    abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
    }
    }
    }

    第二次编辑

    解决方案第二个解决方案使某些设备与我的应用程序不兼容。 @AlexandrDobrovolskiy 在 github 上写的一个新答案对我来说是正确的

    强制 soLoader 到 0.82 版本

    build.gradle文件:
    configurations.all {
    resolutionStrategy {
    force "com.facebook.soloader:soloader:0.8.2"
    }
    }

    关于android - React native 0.61.5 Crashlytics 缺少 libhermes.so : SoLoader. java com.facebook.soloader.SoLoader.assertInitialized,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60054822/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com