onCameraReady not called for Android

#1

Hi there,

I just upgraded from sdk 23 to 27.
The app uses BarCodeScanner, as i’m testing on expo on iPhone 6+ (11.3.1) and Huawei P20 (Android 8.1.0), the iOS works just fine as before but the android doesnt seem to work (cant scan anything).

I put in some console logs in onCameraReady and find only the iOS calls it, and the android one never does. Im guessing thats why it cant scan anything.

                <View style={styles.camera}>
                    <BarCodeScanner
                        type={this.props.cameraFace}
                        onBarCodeRead={this._handleBarCodeRead}
                        autoFocus={Camera.Constants.AutoFocus.on}
                        focusDepth={1}
                        barCodeTypes={[Camera.Constants.BarCodeType.qr]}
                        onCameraReady={this._cameraReady}
                        style={{
                            height: Dimensions.get('window').height,
                            width: Dimensions.get('window').width,
                        }}
                    />
                </View>

Any ideas?

Edit:
Tested on Samsung Galaxy S9+ (8.0.0), no problems. hmmmm
Tested on another Huaweu phone, 8.0.0 also, no problems.

Must be an 8.1.0 issue? Need to test on non Huawei 8.1.0 phones

onBarCodeRead() is never called on Android
#2

Hi-

Here is a Snack of your code so others can easily try.

I think there are some issues with Huawei phones and the barcode scanner right now.
Here is a related Github issue:

#3

Hello, we need to update the docs, we planned to have BarCodeScanner based on Camera (and did for some time) but it resulted in some issues. So if you want to make use of Camera methods and props, just use Camera component

#4

I don’t know if it matters, but when I was working with Camera on android, camera had to be the top component, no View component surrounding it. I’m kind of new, but thought it might help.

#5

I just want to use onBarCodeRead, im sure that is from BarCodeScanner?

#6

Yes, if you just need onBarCodeRead you can just use BarCodeScanner but Camera has this prop as well.

closed #7

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.