web-dev-qa-db-fra.com

React native 0.61.5 Crashlytics manquant libhermes.so: SoLoader.Java com.facebook.soloader.SoLoader.assertInitialized

Je construis une application React-Native , tout fonctionnait bien jusqu'à ce que je décide de passer de la version 0.59.x à v 0,61,5 .

Lorsque j'essaie de publier mon application sur le Play Store, de nombreux plantages sont signalés par Firebase Crashlytics ( v 6.2.0 ) - même si ma version est juste disponible pour les tests internes, donc ça doit être un rapport de pré-lancement déclenché par le playstore - et c'est exactement la même erreur pour le même appareil => LGE Nexus 5X avec 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)

Pour résoudre ce problème, j'ai essayé de soumettre plusieurs versions avec Android) légèrement différente (par exemple avec et sans activation hermes) mais cela ne change pas le résultat final.

Voici mon fichier 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)

De plus, ma racine 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' }
    }
}

Voici les dépendances de mon 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"
  }

J'ai trouvé ces problèmes de github en parlant de ce sujet:

Mais aucune solution décrite ici n'a fonctionné pour moi.

J'ai également trouvé ce fil sur stackoverflow: React-Native: Java.lang.UnsatisfiedLinkError: impossible de trouver DSO à charger: libhermes.so : l'erreur semble être légèrement différente de la mienne, mais les solutions n'ont pas été trouvées. t travailler.

J'ai peur de sortir ma nouvelle version en production et je suis totalement coincé. Besoin d'une aide rapide :)

7
Kruupös

J'ai résolu ce problème en générant un apk plutôt qu'un aab .

Mais à cause du poids supplémentaire généré, je suis profondément insatisfait de ce correctif et j'espère que ce sera une solution temporaire seulement.

Modifier

trouvé une autre solution, j'ai ajouté ceci dans mon build.gradle fichier. Je ne suis pas sûr des effets secondaires mais au moins j'ai cessé d'avoir ces erreurs de crashlytics. Mais il semble que j'ai encore des problèmes avec certains appareils.

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

2ème édition

Solution La 2ème solution rend certains appareils incompatibles avec mon application. Une nouvelle réponse sur github écrite par @AlexandrDobrovolskiy était la bonne pour moi

Forcer soLoader à la version 0.82

dans build.gradle fichier:

configurations.all {
     resolutionStrategy {
       force "com.facebook.soloader:soloader:0.8.2"
     }
}
1
Kruupös