react-native-camera-android icon indicating copy to clipboard operation
react-native-camera-android copied to clipboard

Doesn't work with rn 0.19

Open juggle73 opened this issue 9 years ago • 2 comments

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.

juggle73 avatar Feb 07 '16 18:02 juggle73

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}
/>

Batistleman avatar Feb 22 '16 08:02 Batistleman

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.

sscaff1 avatar Mar 30 '16 19:03 sscaff1