react-native 0.60.4 版本
集成react-native-camera报错如下
- 在
android\app\build.gradle
添加如下默认配置
defaultConfig {
applicationId "com.rn"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
// 下面的是添加
missingDimensionStrategy 'react-native-camera', 'general'
}
- 在
android\build.gradle
添加
allprojects {
repositories {
mavenLocal()
// 下面两个 maven
maven { // 添加
url 'https://maven.google.com/'
name 'Google'
}
maven { // 添加
url 'https://jitpack.io'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
}
}
- 重新编译就可以使用了 用法
// 定义相机组件
import React, { Component } from 'react'
import { RNCamera } from 'react-native-camera';
class Cameras extends Component {
constructor(props){
super(props)
}
render(){
return (
<RNCamera style={{flex:1}}></RNCamera>
)
}
}
export default Cameras