使用expo-image-picker拍照时,expo客户端应用程序崩溃并在拍照后重新加载

发布于 2025-01-11 21:14:11 字数 549 浏览 0 评论 0原文

使用 expo-image-picker 时,我的 Android 手机上的 expo 客户端应用程序在拍照后崩溃。 单击完成符号后,应用程序重新加载

这是我的代码:

import * as ImagePicker from "expo-image-picker";
 const takeImageHandler = async () => {
    const hasPermission = await verifyPermissions();
    if (!hasPermission) {
      return;
    }
    const image = await ImagePicker.launchCameraAsync({
      allowsEditing: true,
      aspect: [16, 9],
      quality: 0.5,
    });
    console.log(image);
  };

when working with expo-image-picker, expo client app on my android phone crashes after taking picture.
after clicking on done symbol the app reloads

here is my code:

import * as ImagePicker from "expo-image-picker";
 const takeImageHandler = async () => {
    const hasPermission = await verifyPermissions();
    if (!hasPermission) {
      return;
    }
    const image = await ImagePicker.launchCameraAsync({
      allowsEditing: true,
      aspect: [16, 9],
      quality: 0.5,
    });
    console.log(image);
  };

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

因为看清所以看轻 2025-01-18 21:14:11

只需尝试使用此代码

const openCamera = async () => {
// Ask the user for the permission to access the camera
const permissionResult = await ImagePicker.requestCameraPermissionsAsync();

if (permissionResult.granted === false) {
  alert("You've refused to allow this appp to access your camera!");
  return;
}

const result = await ImagePicker.launchCameraAsync();

// Explore the result
console.log(result);

if (!result.cancelled) {
  setPickedImagePath(result.uri);
  console.log(result.uri);
}

}

并确保您已使用 npm 最新版本安装了图像选择器
必须再次检查您的 package.json 是否安装了 expo 图像选择器

Just try using this code

const openCamera = async () => {
// Ask the user for the permission to access the camera
const permissionResult = await ImagePicker.requestCameraPermissionsAsync();

if (permissionResult.granted === false) {
  alert("You've refused to allow this appp to access your camera!");
  return;
}

const result = await ImagePicker.launchCameraAsync();

// Explore the result
console.log(result);

if (!result.cancelled) {
  setPickedImagePath(result.uri);
  console.log(result.uri);
}

}

And make sure you have installed image picker using npm latest version
Must check your package.json again that expo image picker is installed or not

ゞ记忆︶ㄣ 2025-01-18 21:14:11

我今天在使用 expo-image-picker 库时遇到了同样的问题。我能够打开相机并拍摄图像,但当我尝试通过单击刻度线保存图像时,应用程序会重新加载。因此,我在另一部手机上进行了测试,效果非常好。

我测试的第一部手机是旧的 Android 手机,第二部是较新的 Android 手机,所以我建议您使用较新/最新的型号。

I had the same problem while working with the expo-image-picker library today. I was able to open the camera and take the image but as soon as i tried to save the image by clicking the tick mark, the app reloaded. So, i tested it on my another phone and it worked perfectly.

The first phone that i was testing on was on old android phone and the second one was a newer android, so i suggest you use a newer/latest model.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文