RNCamera not working on android emulator (black screen)
Which implementation are you using
RNCamera
Steps to reproduce
<RNCamera
ref={(cam) => { this.camera = cam; }}
type={RNCamera.Constants.Type.back}
// onBarCodeRead={this.barcodeRead}
barCodeTypes={[RNCamera.Constants.BarCodeType.qr]}
style={styles.preview}
>
<Text style={styles.capture} onPress={this.emulateScan}>[id: 4 code: 5K0C3H]</Text>
<TouchableOpacity onPress={() => Alert.alert('Alert', 'Keyboard pressed')}>
<Image source={imgKeyboard} style={[styles.icon]} />
</TouchableOpacity>
</RNCamera>
Expected behaviour
Should display a preview screen
Actual behaviour
This code does work on a device in debug mode as expected, but on an emulator displays a black screen. Tested on Android (4.1, 6.0, 7.1.1) ABI x86 with Google API
Environment
- Node.js version: 8.9.0
- React Native version: 0.50.0
- React Native platform + platform version: Android (4.1, 6.0, 7.1.1) ABI x86 with Google API
react-native-camera
Version: "^1.0.0"
Love react-native-camera? Please consider supporting our collective: 👉 https://opencollective.com/react-native-camera/donate
We have to take a look into it but emulators were not a priority to 1.0.0
This happens on real devices as well, at least on Android 5.0.1, 6.0.1
It actually works on real device in debug mode, but can be reproduced in release mode.
This could be a bug with android 6 permissions
I can see this on Android 7
+1
I got the same on my Android 7.0 emulator, running in Linux and Widows too. In my real device, Android 7.1.1 I got the camera working correctly. How can we fix this issue?
on all my emulators I have same issue, however I did check it on 3 real devices and it works ok, however when I install expo camera app using expo on one of emulators it making images correctly
new ResolveTakenPictureAsyncTask(byteBuffer.array(), promise, options).execute();
this line fails, it on only called on Emulators
I'm also getting this error on my emulator, and also on one of my test devices, though we've so far been unable to reproduce the error intentionally on a physical device.
We're finding this issue on Android 7 and 8 on a release build too. Most notably when we use React Navigation and already have a camera (scanning enabled) on one view and then attempt to load another camera on top later on in the navigation stack, wondering if there's a reference issue somewhere as both will be mounted until popped off the stack...
as @tutts mentioned, it can be reproduced in release build on real device
Im getting this issue also
Any solution guys??
I've tracked it down to here.
If you remove the fingerprint check, the webcam does indeed start, at least, on my machine.
//if (!Build.FINGERPRINT.contains("generic")) {
start();
//}
I'm sure this check was put in for a reason. It's been there since the first history entry for RNCameraView.java.
@waitopiggu should we remove this check?
@sibelius Do you know who originally wrote it? It would be good to find out why they put it in before removing it.
As I know this check actually means “if this is emulator” because their fingerprints contain “generic” in the fingerprint... so this is definitely for a reason there :)
On Sun, 15 Apr 2018 at 14:24, waitopiggu [email protected] wrote:
@sibelius https://github.com/sibelius Do you know who originally wrote it? It would be good to find out why they put it in before removing it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/react-native-community/react-native-camera/issues/1234#issuecomment-381402459, or mute the thread https://github.com/notifications/unsubscribe-auth/AEXdyJzYGExfe0mYouIm_269eOsgveKFks5tozvggaJpZM4SDUNn .
@avshenuk Well, I set my emulator webcam to "none" and the app didn't crash, but there was a logcat error.
W/CameraBase: An error occurred while connecting to camera -1: Status(-8): '4: validateConnectLocked:899: No camera device with ID "-1" available'
My remote debugger isn't working for emulated devices, so I can't check if React exceptions are being handled well. I guess they are since the app still works.
@aalices do u know why there is this check?