本文介绍了React Native 0.61.5 Crashlytics缺少libhermes.so:SoLoader.java com.facebook.soloader.SoLoader.assertInitialized的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 React-Native 应用程序,一切正常,直到我决定从0.59.x版本升级到 v 0.61.5

I am building a React-Native application, everything worked fine until I decided to upgrade from version 0.59.x to v 0.61.5.

当我尝试在Play商店中发布我的应用程序时,( v 6.2.0 )-即使我的版本仅适用于内部测试,因此它必须是由playstore触发-对于完全相同的设备,这是完全相同的错误=> 带有Android 6.0.1的LGE Nexus 5X

When I try to release my app in the play store, I've got a lot of crashes reported by Firebase Crashlytics (v 6.2.0) -- even though my version is just available for internal testing, so it must be a pre-launch report triggered by playstore -- and it's exactly the same error for the exact same device => LGE Nexus 5X with 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)提交多个版本,但它不会改变最终结果。

To solved this problem, I tried to submit multiple version with slightly different android configuration (for instance with and without hermes enable) but it doesn't change the end result.

这是我的 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' }
    }
}

这是我的 package.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问题:

I found this github issues talking about this topic :




  • https://github.com/facebook/react-native/issues/25923
  • https://github.com/facebook/hermes/issues/78

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

But no solutions described here were worked for me.

也在stackoverflow上发现了该线程::该错误似乎与f略有不同rom我的,但是解决方案不起作用。

Also found this thread on stackoverflow: React-Native :java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so : the error seems to be slightly different from mine, but solutions didn't work.

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

I'm afraid to release my new version into production and I'm totally stuck. Need fast help :)

推荐答案

我通过生成而不是。

I solved this issue by generating an apk rather than an aab.

但是由于产生了额外的重量,我对此修复程序深为不满,希望它只是一个临时解决方案。

But because of the extra weight generated I'm deeply dissatisfied with this fix, and hope it's a temporary solution only.

编辑

找到了另一个解决方案,我在 build.gradle 文件。我不确定副作用,但至少我不再从crashlytics中遇到此错误。

found another solution, I added this in my build.gradle file. I am unsure of the side-effects but at least I stopped having this errors from crashlytics. But it seems I still have issues with some devices.

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

第二次编辑

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

Solution 2nd solution make some devices incompatible with my app. A new answer on github written by @AlexandrDobrovolskiy was the right one for me

强制soLoader到版本0.82

Forcing soLoader to version 0.82

build.gradle 文件中:

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

这篇关于React Native 0.61.5 Crashlytics缺少libhermes.so:SoLoader.java com.facebook.soloader.SoLoader.assertInitialized的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 20:16