1

昨天我的 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

我试过启用爱马仕

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

在默认配置中

我尝试将 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 错误报告,但没有任何帮助......没有我更新或对项目做任何事情?

提前致谢 ;)

4

1 回答 1

0

您是否尝试过为您获得的每个变体执行此操作?如您所见,我为 qa 变体添加了发布爱马仕 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 一个......)

于 2021-12-10T10:07:34.410 回答