使用构建扫描时,Expo BarCode Scanner 崩溃

Expo's BarCodeScanner crashes when sacaning using the build

使用 Expo 的 BarCodeScanner

扫描条形码时应用崩溃

我对编程和 expo 很陌生,所以对于不够精确,我提前表示歉意。
我使用 expo’s expo-barcode-scanner 使用 Expo 34.0.1 创建了一个应用程序。该应用程序在 expo start 上完美运行;但是,当我 运行 expo build:android 扫描失败时。相机打开,但一旦扫描代码,应用程序就会重新启动。

(我没有在IOS上测试)

"expo": "^34.0.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
"sdkVersion": "33.0.0",
import { BarCodeScanner } from 'expo-barcode-scanner';
import * as Permissions from 'expo-permissions';
<BarCodeScanner
        onBarCodeScanned={this.handleBarCodeScanned}
        style={StyleSheet.absoluteFill}
>
</BarCodeScanner>

我希望它能像在开发中一样工作,但应用程序会在扫描代码后立即重新启动

谢谢!

问题出在您的权限设置方式上。您需要检查从哪里调用您的权限。我从 componentWillMount()

调用了我的