SoLoader:找不到要加载的DSO:libjsijniprofiler.so,原因是:dlopen失败:库“libhermes.so”

5

昨天我的React Native应用程序运行良好,但在编译(gradle和build)成功并运行应用程序后,我收到了以下错误消息:

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

在过去的两天里,我尝试了100种不同的解决方案...

我已经尝试了:

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

我有这个项目的 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()
    }
}

我已经尝试了app/build.gradle中packagingOptions的各种组合。

    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'*/
    }

我尝试升级React Native版本从0.65.1到0.66.0。

我尝试启用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
    

我尝试过。

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

在 defaultConfig 中

我尝试将 jscFlavor 从 jsc 更改为 jsc-intl

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

我尝试了不同版本的AndroidStudio。 我在Windows机器上尝试,而不是我的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

应用级别的 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)

当然,我也尝试了一下。

gradlew clean
react-native start --clean-cache 

所有这些东西。

请任何人帮忙!我已经尝试了谷歌上的每个相关链接,并阅读了我能找到的每个git错误报告,但都没有帮助...而且我没有更新或对项目做任何操作?

提前感谢;)


你是如何解决这个问题的? - vinnybad
2个回答

0

你尝试过针对每个变体都这样做吗?正如你所看到的,我为qa变体添加了发布hermes aar。

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

在我添加了我的qa变体之后,这对我有些起作用,但它仍然失败了,但是出现了不同的错误: 无法找到要加载的DSO:libhermes.so,原因是:无法找到要加载的DSO:libjsi.so

我可以看到在qa apk中它确实有libhermes.so(只是缺少libjsi.so...)


-1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接