I'm trying to use "React-native-camera" library in my project. I've literally done this over 50 times and everything went fine each time both on my mac and Linux System.
But now out of a sudden it wont work on my Linux System anymore and keeps generating this error (works on mac though!).
I've checked all the configuring steps here I've tried adding missingDimensionStrategy 'react-native-camera', 'general' to app build.gradle I've tried adding maven {url "https://jitpack.io"} and maven {url "https://maven.google.com"} to project build.gradle I've tried removing madules.xml from .ideas directory and restarting android studio both with and without cache clearing.
still nothing This was my sample code to get the camera module going:
class CameraApp extends Component {
constructor(props) {
super(props);
this.state = {
path: null,
uri: '',
imageName: ''
};
}
takePicture() {
this.camera.capture()
.then((data) => {
console.log(data);
})
.catch(err => console.error(err));
}
renderCamera() {
return (
<View>
<Camera
ref={(cam) => {
this.camera = cam;
}}
style={styles.preview}
aspect={Camera.constants.Aspect.fill}
captureTarget={Camera.constants.CaptureTarget.disk}
>
<TouchableHighlight
style={styles.capture}
onPress={this.takePicture.bind(this)}
underlayColor="rgba(255, 255, 255, 0.5)"
>
<View />
</TouchableHighlight>
</Camera>
</View>
);
}
render() {
return (
<View style={styles.container}>
{this.renderCamera()}
</View>
);
}
};
There are three issues here:
First, the import should be like:
import {RNCamera as Camera} from 'react-native-camera';
Second, the constants
must have the first letter capitalized: Constants
Third, both Aspect.fill
and CaptureTarget.disk
are no longer part of the Constants
. So you should delete the following two lines:
aspect={Camera.constants.Aspect.fill}
captureTarget={Camera.constants.CaptureTarget.disk}
And you may check for the updated alternatives of those constants at there official documentation at https://react-native-community.github.io/react-native-camera/docs
I found this link, maybe helpful to you (it work for me): Issue #1288 react-native-camera
You should import like this:
import { RNCamera } from 'react-native-camera';
Not like this
import Camera from 'react-native-camera';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With