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

RNCamera not working on android emulator (black screen)

Open cvvspb opened this issue 8 years ago • 25 comments

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

cvvspb avatar Feb 13 '18 07:02 cvvspb

We have to take a look into it but emulators were not a priority to 1.0.0

jgfidelis avatar Feb 13 '18 11:02 jgfidelis

This happens on real devices as well, at least on Android 5.0.1, 6.0.1

rasom avatar Feb 14 '18 06:02 rasom

It actually works on real device in debug mode, but can be reproduced in release mode.

rasom avatar Feb 14 '18 06:02 rasom

This could be a bug with android 6 permissions

sibelius avatar Feb 14 '18 07:02 sibelius

I can see this on Android 7

asemiankevich avatar Feb 14 '18 08:02 asemiankevich

+1

ejswenson15 avatar Feb 19 '18 20:02 ejswenson15

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?

araujobarret avatar Feb 21 '18 12:02 araujobarret

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

tobob avatar Feb 21 '18 13:02 tobob

new ResolveTakenPictureAsyncTask(byteBuffer.array(), promise, options).execute();

this line fails, it on only called on Emulators

tobob avatar Feb 21 '18 15:02 tobob

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.

Tsiniloiv avatar Mar 05 '18 14:03 Tsiniloiv

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...

tutts avatar Mar 19 '18 22:03 tutts

as @tutts mentioned, it can be reproduced in release build on real device

rasom avatar Mar 23 '18 18:03 rasom

Im getting this issue also

CPCherrington avatar Apr 04 '18 04:04 CPCherrington

Any solution guys??

Reyhanahmed avatar Apr 12 '18 12:04 Reyhanahmed

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 avatar Apr 15 '18 12:04 waitopiggu

@waitopiggu should we remove this check?

sibelius avatar Apr 15 '18 12:04 sibelius

@sibelius Do you know who originally wrote it? It would be good to find out why they put it in before removing it.

waitopiggu avatar Apr 15 '18 12:04 waitopiggu

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 avatar Apr 15 '18 12:04 avshenuk

@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.

waitopiggu avatar Apr 15 '18 12:04 waitopiggu

@aalices do u know why there is this check?

sibelius avatar Apr 15 '18 12:04 sibelius