如何在 Android Studio 中手动链接 react-native-camera?
Posted
技术标签:
【中文标题】如何在 Android Studio 中手动链接 react-native-camera?【英文标题】:How can I manually link react-native-camera in Android Studio? 【发布时间】:2019-10-25 21:39:24 【问题描述】:澄清一下,我正在使用 android Studio 运行 Windows 计算机。
我正在尝试在 react 本机应用程序中使用 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 吗?我真的很感激。
【问题讨论】:
【参考方案1】:看起来您正在使用新版本的 react-native(0.60 或更高版本)。在这种情况下,您不必自己链接库,因为支持最新 react-native 的库现在会在安装时自行链接。
你应该能够做到npm install react-native-camera --save
并让它工作。如果您之前使用过react-native link react-native-camera
,您现在可能需要运行react-native unlink react-native-camera
来恢复链接命令所做的操作。您可能还需要重新安装库(npm uninstall react-native-camera
后跟 npm install react-native-camera --save
)。如果还是不行可以通过manual installation of this library
【讨论】:
谢谢。我对 react native 编程还很陌生,之前我并不真正了解自动链接功能。以上是关于如何在 Android Studio 中手动链接 react-native-camera?的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Android Studio 中手动安装 App Engine?
Android Studio 如何手动运行 gradle 同步?
我在构建应用程序时在 android studio 中遇到了 Android 资源链接失败错误。我不知道如何解决这个问题。我是 Android Studio 的新手 [关闭]