expo / expo

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.
https://docs.expo.dev
MIT License
33.9k stars 5.43k forks source link

interleaved2of5 does not work on Android #19230

Closed felpereira closed 2 years ago

felpereira commented 2 years ago

Summary

https://docs.expo.dev/versions/latest/sdk/bar-code-scanner/

When I execute the code exemple from here in Android I can't read a interleaved2of5

but if I execute the same exemple in IOS it works perfectly

What platform(s) does this occur on?

Android, iOS

Environment

  expo-env-info 1.0.5 environment info:
    System:
      OS: Windows 10 10.0.19044
    Binaries:
      Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
      npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD   
    IDEs:
      Android Studio: AI-212.5712.43.2112.8609683     
    npmPackages:
      expo: ~46.0.9 => 46.0.10 
      react: 18.0.0 => 18.0.0 
      react-native: 0.69.5 => 0.69.5 
    Expo Workflow: managed

Version IOS: 15.3.1 Iphone 6s Plus

Version Android: 12 samsung s20Fe

Minimal reproducible example

Run lines below to create an expo application

npx create-expo-app my-app cd my-app

Change app.js to

import React, { useState, useEffect } from 'react';
import { Text, View, StyleSheet, Button } from 'react-native';
import { BarCodeScanner } from 'expo-barcode-scanner';

export default function App() {
  const [hasPermission, setHasPermission] = useState(null);
  const [scanned, setScanned] = useState(false);

  useEffect(() => {
    const getBarCodeScannerPermissions = async () => {
      const { status } = await BarCodeScanner.requestPermissionsAsync();
      setHasPermission(status === 'granted');
    };

    getBarCodeScannerPermissions();
  }, []);

  const handleBarCodeScanned = ({ type, data }) => {
    setScanned(true);
    alert(`Bar code with type ${type} and data ${data} has been scanned!`);
  };

  if (hasPermission === null) {
    return <Text>Requesting for camera permission</Text>;
  }
  if (hasPermission === false) {
    return <Text>No access to camera</Text>;
  }

  return (
    <View style={styles.container}>
      <BarCodeScanner
        onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
        style={StyleSheet.absoluteFillObject}
      />
      {scanned && <Button title={'Tap to Scan Again'} onPress={() => setScanned(false)} />}
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

then i execute

expo start --android or expo start --ios

brentvatne commented 2 years ago

this is in the documentation:

image
felpereira commented 2 years ago

If you use the code above, you will find that it parses what the camera captures and returns what type it is, when I use it on iPhone it returns interleaved2of5 on android it doesn't recognize anything

I did some tests defining the type, and it didn't work either

brentvatne commented 2 years ago

hey @felpereira - the title of this issue is "interleaved2of5 does not work on Android" and I'm just pointing out that the docs indicate that this is expected behavior. is there something else that is the issue that is different from what is described in the title?

felpereira commented 2 years ago

@brentvatne sorry, the description was fine for me. I'm really sorry

But it's exactly as commented, if I use the Minimal reproducible example and point the camera on a cell phone that has an android at an image that contains interleaved2of5, it won't recognize anything, neither itf14 nor interleaved2of5.

brentvatne commented 2 years ago

ah yeah the docs aren't so clear about this - you should use an itf14 barcode rather than interleaved2of5 if you need to support android

felpereira commented 2 years ago

I tried using itf14, and I also tried using other forms. I've been trying for 2 days. did you get to test it?

@brentvatne I tried, in my example, which was made available in the documentation, it doesn't work