react-native-camera-android
react-native-camera-android copied to clipboard
Doesn't work with rn 0.19
I tried to test camera with rn 0.19 app. Following code was added in MainActivity.java:
import com.ReactCamera.RNCameraViewPackage; // <--- import
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNCameraViewPackage() // <--- create package
);
}
But when view is loaded I can see just white screen with no errors.
You need to add a height for the view:
<CameraAndroid
style={{flex: 1,justifyContent: 'flex-end',alignItems: 'center',height: Dimensions.get('window').height,width: Dimensions.get('window').width}}
ref="cam" // the reference of your camera view
type={"back"} // the type of your camera
autoFocus={true}
torchMode={"off"} // flashlight settings of your camera
viewFinderDisplay={true} // set it to true if you want to scan barcodes
onBarCodeRead={this._barcodeReceived}
onPictureTaken={this._onPictureTaken}
/>
Change
new RNCameraViewPackage() // <--- create package
to
new RNCameraViewPackage(this) // <--- create package
The white screen you're referring to means that RN is sick of showing you the error and just goes to that screen for some reason. It doesn't have to do with the styling of the view.