【问题标题】:What's causing Expo's ImagePicker.launchCameraAsync() to crash the app on some android devices?是什么导致 Expo 的 ImagePicker.launchCameraAsync() 在某些 android 设备上使应用程序崩溃?
【发布时间】:2021-03-29 16:21:14
【问题描述】:

我有一个使用 expo SDK 39 和 expo 图像选择器(“expo-image-picker”:“~9.1.0”)的托管 expo 应用程序,目前正在生产中。一些 android 用户报告了调用 ImagePicker.launchCameraAsync() 的相机功能“不工作”。我已经能够在运行 android 10 的 Nexus S 模拟器上重现它,整个应用程序崩溃。没有记录错误消息。

我认为该问题特定于 Android 10,但一些用户报告了 Android 11(和 android 8)上的问题。

我尝试包装一个 try-catch 块以提取错误,但没有成功,应用程序仍然崩溃,并且没有日志。

我还尝试制作一个仅具有上述功能的虚拟应用程序,但在 Nexus S 模拟器上得到相同的结果:应用程序崩溃,没有记录报告。

这是触发崩溃的函数调用示例。

const takeImage = async () => {
    let result = await ImagePicker.launchCameraAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.Images,
      allowsEditing: true,
        aspect: [4, 3],
      quality: 1,
      base64: true,
    });
    if (!result.cancelled) {
      console.log(result.uri);
    }
  };

【问题讨论】:

    标签: android react-native expo


    【解决方案1】:

    这个问题在github上讨论https://github.com/expo/expo/issues/7946

    expo docs 中的以下注释似乎与该问题有关:

    Note: Make sure that you handle MainActivity destruction on Android. See ImagePicker.getPendingResultAsync.
    

    但是,文档似乎在描述如何处理发生在 拍照后发生的崩溃。问题中描述的崩溃在调用 imagePicker 的相机方法时立即发生。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 2013-02-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多