简体   繁体   English

世博相机 takePictureAsync() 在 Android 上不起作用

[英]expo-camera takePictureAsync() not working on Android

I recently updated several lines of code in a managed expo project, unrelated to the camera functionality.我最近更新了托管博览会项目中的几行代码,与相机功能无关。 It still works fine on iOS, only Android does not work.它在 iOS 上仍然可以正常工作,只有 Android 无法正常工作。 I had released a previous version one month ago that worked well.一个月前我发布了一个运行良好的先前版本。 When I revert back to the old commit from then, though, it also does not work on Android (iOS fine).但是,当我从那时起恢复到旧的提交时,它在 Android 上也不起作用(iOS 很好)。

  • expo 44.0.6世博会 44.0.6
  • expo-camera 12.1.2世博相机 12.1.2
  • react 17.0.1反应 17.0.1
  • react-native 0.64.3反应原生 0.64.3

There is no issue launching the camera, etc. Rather, the issue occurs at takePictureAsync, which hangs and then does not return anything.启动相机等没有问题。相反,问题发生在 takePictureAsync,它挂起然后不返回任何内容。

const snapPic = async () => {
    const { status } = await Camera.getCameraPermissionsAsync();
    if (status != 'granted') {
        alert('Please grant access to camera and retry.');
        await Camera.requestCameraPermissionsAsync();
        return;
    }
    const options = { quality: 0.1 };
    const photo = await this.camera.takePictureAsync(options);
    this.camera.pausePreview();
    this.setState({imageSource: photo.uri});
};

<Camera style={styles.cameraBox} ref={ref => {this.camera = ref}} />

Please let me know what other information I can provide, if necessary.如有必要,请告诉我我可以提供哪些其他信息。 Thanks in advance!提前致谢!

Instead of pause preview method.而不是暂停预览方法。 Try it with skipProcessing to false inside option object尝试在选项对象内使用 skipProcessing 为 false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 [React Native][expo-camera] 损坏的 base64 保存在 Android 上的图像 - [React Native][expo-camera] Corrupt base64 saved image on Android Expo 相机的 takePictureAsync 不返回任何内容。 (承诺从未兑现) - takePictureAsync of Expo's Camera returns nothing. (Promise never fulfilled) "未定义不是对象(评估 &#39;_$$_REQUIRE(_dependencyMap[5], &quot;expo-camera&quot;).Camera&#39;)" - Undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[5], "expo-camera").Camera') react-native-camera (android): takePictureAsync() 抛出错误 - react-native-camera (android): takePictureAsync() throws error camera.takePictureAsync(options) 不是反应原生相机中的 function - camera.takePictureAsync(options) is not a function in react native camera Swipable 在 Android 中不起作用(Expo Cli) - Swipable is not working in Android (Expo Cli) 错误:expo-camera.isAvailableAsync 和 expo-camera.getAvailableCameraTypesAsync 在 android 上不可用 - errors: expo-camera.isAvailableAsync and expo-camera.getAvailableCameraTypesAsync is not available on android Android平板电脑相机无法正常工作 - Android tablet camera not working Android-相机预览不起作用 - Android - camera preview not working 相机无法在移动设备上运行(Android) - Camera not working on mobile (Android)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM