我创建了一个新的react-native 项目,并添加了我的android原生模块作为依赖项.使用官方文件https://reactnative.dev/docs/native-modules-setup

当我运行此命令时,我得到以下堆栈跟踪错误:

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libfbjni.so result: 0
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:825)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:673)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:611)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:559)
        at com.facebook.soloader.NativeLoaderToSoLoaderDelegate.loadLibrary(NativeLoaderToSoLoaderDelegate.java:25)
        at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:44)
        at com.facebook.jni.HybridData.<clinit>(HybridData.java:34)
        at com.facebook.flipper.android.FlipperThread.run(FlipperThread.java:25) 

以下是我的package.json

{
  "name": "albums",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "axios": "^0.19.2",
    "react": "16.11.0",
    "react-native": "0.62.0-rc.5",
    "react-native-my-fancy-library": "../react-native-my-fancy-library/"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/runtime": "^7.9.2",
    "@react-native-community/eslint-config": "^1.0.0",
    "babel-jest": "^25.3.0",
    "eslint": "^6.8.0",
    "jest": "^25.3.0",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.11.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

我已经试过了:

https://stackoverflow.com/a/61695629/9715339

https://stackoverflow.com/a/57155606/9715339

https://github.com/facebook/react-native/issues/25415

但这些都没有解决我的问题.

我是英语初学者.所以我不知道我还需要在这里发布哪些详细信息文件.如果你需要其他文件,一定要告诉我.

推荐答案

对我来说,以下两种方法解决了这个问题(我认为是后者解决了这个问题):

  1. 重置缓存:react-native start --reset-cache
  2. 清洁安卓:cd android->;./gradlew clean

React-native相关问答推荐

如何停止在Expo路由中将新文件显示为菜单列表?

收到错误Constants.platform.ios.model已被弃用,以支持 expo-device

用图像 react native 动画进度条

React Native - 为什么我们对 Image 组件使用 tintColor 属性?

在 create-react-native-app 元素中突然看到错误Plugin/Preset files are not allowed to export objects, only functions

React Native StackNavigator 初始路由名称

在 CircleCI 上 ReactNative 0.59.x build fails on CircleCI with exit value 137

图像背景ResizeMode调整大小模式

如何启用 stacktrace react-native run-android 命令?

运行react应用程序时出错

React Native 中的全屏图像

我可以在 react-native 中使用 reactJS 库吗?

为什么 Android Studio 强制使用 Android 支持库中的 Androidx?

react-native Http 拦截器

为什么,确切地说,我们需要 React.forwardRef?

如何将捕获的图像与 react-native-camera 一起使用

react-native run-ios 运行失败: Application is unknown to FrontBoard?

Ipad 上的 React Native - 错误 - could not connect to development server

React Native 元素,未生成 index.ios.js 或 index.android.js

如何使 react-native Picker 停留在新 Select 的选项?