如何在 Android Studio 中手动 link react-native-camera?

How can I manually link react-native-camera in Android Studio?

澄清一下,我是 运行 一台使用 Android Studio 的 Windows 计算机。

我正在尝试在 React Native 应用程序中使用 React-Native-camera 设置 QR 码扫描仪。

我可以毫无问题地安装库:

$ npm install react-native-camera --save

给予

npm WARN babel-eslint@10.0.1 requires a peer of eslint@>= 4.12.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-eslint-comments@3.1.2 requires a peer of eslint@>=4.19.1 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-flowtype@2.50.3 requires a peer of eslint@>=2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-jest@22.4.1 requires a peer of eslint@>=5 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react@7.12.4 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react-hooks@1.6.1 requires a peer of eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-react-native@3.6.0 requires a peer of eslint@^3.17.0 || ^4 || ^5 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename '[file location]\node_modules\.staging\fsevents-7a20bca6\node_modules\needle' -> '[file location]\node_modules\.staging\needle-41ea96cc'


+ react-native-camera@3.8.0
updated 1 package and audited 948127 packages in 76.202s
found 0 vulnerabilities

我看到的每一个网上参考,比如https://facebook.github.io/react-native/docs/linking-libraries-ios 如果您在 Mac.

上为 iOS 编程,似乎只会给出说明

https://react-native-community.github.io/react-native-camera/docs/installation 库的文档建议使用

自动链接

$ react-native link react-native-camera.

我得到:

info Linking "react-native-camera" iOS dependency
info iOS module "react-native-camera" has been successfully linked
info Linking "react-native-camera" Android dependency
info Android module "react-native-camera" has been successfully linked

在我的设备上构建它时出现问题,使用 $ react-native run-android,我得到:

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  - react-native-camera (to unlink run: "react-native unlink react-native-camera")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md

手动链接的唯一结果是在 XCode 上,但是有人可以帮助我使用 Android Studio 吗?非常感谢。

您似乎正在使用新版本的 react-native(0.60 或更高版本)。在这种情况下,您不必自己 link 您的库,因为现在支持最新的 react-native 的库 link 在安装后会自己

您应该能够做到 npm install react-native-camera --save 并让它发挥作用。如果您之前使用过 react-native link react-native-camera,您现在可能需要 运行 react-native unlink react-native-camera 来还原 link 命令所做的事情。您可能还需要重新安装库(npm uninstall react-native-camera 后跟 npm install react-native-camera --save)。如果还是不行你可以通过manual installation of this library