react-native 实现拍照上传及扫描二维码功能
自从入了rn项目的坑,开始了踩坑历程,下面总结一下拍照上传遇见的坑:
使用的主要插件是:react-native-camera
和 react-native-image-picker
“react-native”: “0.59.9”
“react-native-camera”: “git+https://git@github.com/react-native-community/react-native-camera”
“react-native-image-picker”: “^2.3.1”
安装 react-native-camera
- 安装步骤这里省略,按照 npm 安装步骤没什么问题:npm安装步骤
P.S. 我这里的rn版本< 0.60.x
, 所以安装完成之后需要react-native link
一下 - 但是安装完成之后会遇见各种报错问题,下面汇总一下安装出现的问题及解决方式
安装报错问题汇总处理
异常 1
What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve project :react-native-camera.
Required by:
project :app
> Cannot choose between the following variants of project :react-native-camera:
- generalDebugRuntimeElements
- mlkitDebugRuntimeElements
All of them match the consumer attributes:
- Variant 'generalDebugRuntimeElements' capability baidupush:react-native-camera:unspecified:
- Unmatched attributes:
- Found com.android.build.api.attributes.VariantAttr