skip to Main Content

Yesterday my react-native app worked fine, but after the compiles (gradle and build) successfully and runs the app, I get the following error message:

2021-10-08 14:51:51.378 7178-7178/com.appname E/SoLoader: couldn't find DSO to load: libjsijniprofiler.so caused by: dlopen failed: library "libhermes.so" not found: needed by /data/app/~~p8ttNiYyXwU4wozNVHBjGQ==/com.appname-nVEXUjtlwdrOPFZH2SvGwQ==/lib/x86/libjsijniprofiler.so in namespace classloader-namespace result: 0
2021-10-08 14:51:51.382 7178-7178/com.appname E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.appname, PID: 7178
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjsijniprofiler.so caused by: dlopen failed: library "libhermes.so" not found: needed by /data/app/~~p8ttNiYyXwU4wozNVHBjGQ==/com.appname-nVEXUjtlwdrOPFZH2SvGwQ==/lib/x86/libjsijniprofiler.so in namespace classloader-namespace result: 0

I’ve tried 100 different proposed solutions in the last two days…
I’ve tried:

implementation 'com.facebook.soloader:soloader:0.9.0+'

I have this is the project’s build.gradle:

    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")
        }
        maven { url "https://jitpack.io" }
        jcenter()
        google()
        mavenCentral()
    }
}

I have tried all kinds of combinations in packagingOptions in app/build.gradle

    packagingOptions {
        pickFirst 'lib/arm64-v8a/libjsc.so'
        pickFirst 'lib/x86_64/libjsc.so'
        /*pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'*/
    }

I tried upgrading react-native from 0.65.1 to 0.66.0

I’ve tried enabling hermes

project.ext.react = [
        entryFile: "index.js",
        enableHermes: true,  // clean and rebuild if changing
]
def enableHermes = project.ext.react.get("enableHermes", true)
...
if (enableHermes) {
     def hermesPath = "../../node_modules/hermes-engine/android/";
     debugImplementation files(hermesPath + "hermes-debug.aar")
     releaseImplementation files(hermesPath + "hermes-release.aar")
else {
     implementation jscFlavor
    

I tried

ndk { abiFilters 'armeabi-v7a', 'x86' }

in defaultConfig

I’ved tried changing jscFlavor from jsc to jsc-intl

def jscFlavor = 'org.webkit:android-jsc-intl:+'
//def jscFlavor = 'org.webkit:android-jsc:+'

I tried different versions of AndroidStudio.
I tried on a Windows machine instead of my Mac.

$> npm info
System:
    OS: macOS 11.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
    Memory: 49.68 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.10.0 - /usr/local/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 7.24.0 - /usr/local/bin/npm
    Watchman: 2021.10.04.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /Users/rubenmagic/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
    Android SDK:
      Android NDK: 22.1.7171670
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7678000
    Xcode: 13.0/13A233 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: 6.0.1 => 6.0.1
    react: ^17.0.2 => 17.0.2
    react-native: ^0.66.0 => 0.66.0
    react-native-macos: Not Found

app–level build.gradle

apply plugin: "com.android.application"

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

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

def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc-intl:+'
//def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", true)

android {
    //ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion 30

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    repositories {
        flatDir { dirs 'libs' }
    }

    defaultConfig {
        applicationId "com.incidentshare"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "0.7.0"
        buildConfigField "String", "EXO_VERSION", ""2.11.4""
        multiDexEnabled true //Ruben TODO: Try and disable for performance upgrade
        ndk {
            //abiFilters 'armeabi-v7a', 'x86'
        }
    }
    /*splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }*/
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    // 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(com.android.build.OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
            }
        }
    }
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion '28.0.0'
                }
            }
        }
    }*/
    packagingOptions {
        pickFirst 'lib/arm64-v8a/libjsc.so'
        //pickFirst 'lib/x86_64/libjsc.so'
        /*pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'*/
    }
}

dependencies {
    implementation "com.facebook.soloader:soloader:0.9.0+"

    apply from: '../../node_modules/react-native-unimodules/gradle.groovy'
    addUnimodulesDependencies()

    implementation (name: 'libgrafika-release', ext: 'aar')
    implementation (name: 'libsldp-release', ext: 'aar')

    //implementation project(':appBroadcast')

    //noinspection GradleDynamicVersion
    implementation 'com.facebook.soloader:soloader:0.10.1'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
    implementation 'com.google.android.material:material:1.4.0'
    implementation "com.facebook.react:react-native:${reactNativeVersion}"  // From node_modules
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"


    implementation 'com.github.satyan:sugar:1.4'
    implementation 'androidx.annotation:annotation:1.2.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'com.github.seancfoley:ipaddress:5.3.3'

    implementation "com.google.android.exoplayer:exoplayer-core:2.13.3"
    implementation "com.google.android.exoplayer:exoplayer-dash:2.13.3"
    implementation "com.google.android.exoplayer:exoplayer-hls:2.13.3"
    implementation "com.google.android.exoplayer:exoplayer-ui:2.13.3"
    implementation 'com.google.android:flexbox:2.0.1'
    implementation 'com.github.permissions-dispatcher:permissionsdispatcher:4.9.1'

    implementation platform('com.google.firebase:firebase-bom:27.1.0')
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-core'
    //implementation 'com.google.firebase:firebase-messaging'
    //implementation "com.google.firebase:firebase-messaging:22.0.0"
    implementation project(':react-native-push-notification')
    annotationProcessor 'org.permissionsdispatcher:permissionsdispatcher-processor:4.7.0'
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })


    testImplementation 'junit:junit:4.13'

    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.fbjni'
    }

    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }

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

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

Oh and of cause I tried

gradlew clean
react-native start --clean-cache 

and all that stuff.

Please anyone help! I’ve tried every releated link on google, and read through every git bug report i could find and nothing helps… Without me updating or doing anything to the project?

Thanks in advance 😉

2

Answers


  1. have you tried doing this for each variant you got ? as you can see I added for the qa variant the release hermes aar.

    debugImplementation files(hermesPath + "hermes-debug.aar")
    qaImplementation files(hermesPath + "hermes-release.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
    

    that worked somewhat for me after I added the qa variant of mine, however it still fails but with different error:
    couldn’t find DSO to load: libhermes.so caused by: couldn’t find DSO to load: libjsi.so

    and I can see in the qa apk that it does have the libhermes.so (just missing the libjsi.so one… )

    Login or Signup to reply.
  2. Update the SoLoader version you are using.

    https://github.com/facebook/SoLoader/releases

    It is fixed in v0.10.3

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search