我正在try 将React Native与我现有的Android应用程序集成.我在初始化React Native Screen时遇到以下异常:

JAVAlang.UnsatisfiedLinkError:dlopen失败:

The App is only crashing on 64-bit devices.

根据我到目前为止的学习,我在React Native Repo上发现了这issue个报告,但这篇文章中建议的solution个没有帮助,因为我没有在现有应用中使用任何外部so库.

除此之外,我还意识到安装我的应用程序的设备在库 struct 上的另一个差异.我正在比较我的应用程序和react-native 演示应用程序的 struct .

React demo App

root@generic_x86_64:**/data/data/com.react.demo/lib** # ls
libfb.so
libfolly_json.so
libglog.so
libglog_init.so
libgnustl_shared.so
libicu_common.so
libimagepipeline.so
libjsc.so
libreactnativejni.so
libreactnativejnifb.so

root@generic_x86_64:/data/data/**com.react.demo**/lib-main # ls
dso_deps
dso_lock
dso_manifest
dso_state

My App

root@generic_x86_64:/data/data/**com.my.app**/lib-main # ls
dso_deps
dso_lock
dso_manifest
dso_state
libfb.so
libfolly_json.so
libglog.so
libglog_init.so
libgnustl_shared.so
libicu_common.so
libimagepipeline.so
libjsc.so
libreactnativejni.so
libreactnativejnifb.so

分享关于我的项目的更多细节:

package.json

{
  "name": "projectname",
  "version": "1.0.0",
  "description": "Native NPM",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "Ishan D",
  "license": "ISC",
  "dependencies": {
    "react": "^15.3.2",
    "react-native": "^0.37.0",
    "react-native-linear-gradient": "^1.5.15",
    "rn-viewpager": "^1.1.3"
  },
  "devDependencies": {}
}

dependencies used in android native project

ext {
    compileSdkVersion = 24
    buildToolsVersion = '24.0.2'
    minSdkVersion = 16
    targetSdkVersion = 24
    supportLibrariesVersion = '23.0.1'
    playServiceVersion = '9.0.2'

    dep = [
            fabricPlugin          : 'io.fabric',
            fabricMavenUrl        : 'https://maven.fabric.io/public',
            fabricClasspath       : 'io.fabric.tools:gradle:1.+',

            playServiceClasspath  : 'com.google.gms:google-services:1.3.0-beta1',
            playServicePlugin     : 'com.google.gms.google-services',

            playServiceAppindexing: "com.google.android.gms:play-services-appindexing:$playServiceVersion",
            playServiceLocation   : "com.google.android.gms:play-services-location:$playServiceVersion",
            playServiceVision     : "com.google.android.gms:play-services-vision:$playServiceVersion",
            playServiceAuth       : "com.google.android.gms:play-services-auth:$playServiceVersion",
            playServiceBase       : "com.google.android.gms:play-services-base:$playServiceVersion",
            playServiceIdentity   : "com.google.android.gms:play-services-identity:$playServiceVersion",
            playServiceAnalytics  : "com.google.android.gms:play-services-analytics:$playServiceVersion",
            playServiceGcm        : "com.google.android.gms:play-services-gcm:$playServiceVersion",

            underCouchClasspath   : 'de.undercouch:gradle-download-task:2.0.0',
            underCouchPluigin     : 'de.undercouch.download',

            crashlytics           : 'com.crashlytics.sdk.android:crashlytics:2.4.0@aar',

            moengage              : 'com.moengage:moe-android-sdk:6.0.29',

            supportV4             : "com.android.support:support-v4:$supportLibrariesVersion",
            supportAppCompatV7    : "com.android.support:appcompat-v7:$supportLibrariesVersion",
            supportCardviewV7     : "com.android.support:cardview-v7:$supportLibrariesVersion",
            supportDesignV7       : "com.android.support:design:$supportLibrariesVersion",

            okhttp                : 'com.squareup.okhttp:okhttp:2.5.0',
            junit                 : 'junit:junit:4.12',
            mockito               : 'org.mockito:mockito-core:1.10.19'
    ]
}

任何线索都将不胜感激.

PS:我知道react native支持64位二进制文件,我不使用任何外部库.

推荐答案

将以下内容添加到app/gradle文件中

defaultConfig {
....

    ndk {
        abiFilters "armeabi-v7a", "x86", 'armeabi', 'arm64-v8a'
    }

    packagingOptions {
        exclude "lib/arm64-v8a/libgnustl_shared.so"
    }
}

还要确保使用相同的端口.

adb reverse tcp:8081 tcp:8081

React-native相关问答推荐

复活的夹子在Panguesture上崩溃

NativeWind边框 colored颜色 在Reaction Native应用程序中未按预期工作

如何将S的此API输出输出到平面列表中?控制台将数据及其可视记录到平面列表中,但我无法输出到平面列表中

导航到另一个屏幕后清空搜索屏幕

React-Native-Web 错误:rnw_blogpost.bundle.js:1414 Uncaught TypeError: Cannot read properties of undefined (reading 'isBatchingLegacy')

React Native - 如何在从另一个屏幕导航后将 ScrollView 滚动到给定位置

是否有用于react-native 的简单同步存储选项?

React Native Ios错误 - ENOENT:no such file or directory, uv_cwd (null)

Eslint 错误,configuration for rule "import/no-cycle" is invalid

React Native:在 ScrollView contentContainerStyle 上设置 flex:1 会导致组件重叠

IntelliSense 在第一项后无法在 React Native 样式表中工作

为什么会出现此错误:Invariant Violation: Cannot update during an existing state transition

React Native 上传到 S3 存储空间

如何在 React Native 的 Modal 组件上禁用Swipe down to close?

在 react-native 元素中更改 android 和 ios 的入口文件路径

try 添加包时出现错误duplicate entry:com/google/android/gms/internal/zzble.class

在react native 中出现Cannot read property 'pick算法rithm' of null错误

react-native fetch() cookie 持久化

使用 Jest 的 react-navigation 测试组件

React Native 不支持在 Windows 上开发?