安装步骤
1.npm install react-native-camera --save
2.android/app/src/main/AndroidManifest.xml为您的应用文件添加权限:
<!-- Required -->
<uses-permission android:name="android.permission.CAMERA" />
<!-- Include this only if you are planning to use the camera roll -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Include this only if you are planning to use the microphone for video recording -->
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
3.在 中插入以下行android/app/build.gradle:
android {
...
defaultConfig {
...
missingDimensionStrategy 'react-native-camera', 'general' // <--- insert this line
}
}
4.出现问题时的附加信息
- 确保您使用
JDK >= 1.7和您的buildToolsVersion >= 25.0.2 - 确保您已添加 jitpack
android/build.gradle
allprojects {
repositories {
maven { url "https://www.jitpack.io" }
maven { url "https://maven.google.com" }
}
}