我试图让用户使用"launchCameraAsync“功能与”世博-图像选择器“模块拍照,一开始一切都很好,但现在当试图让用户拍照时,世博会会发出警告而不激活相机,警告是:
可能未处理的承诺拒绝(id: 0):错误:调用函数'ExponentImagePicker.launchCameraAsync‘已被拒绝。由: java.lang.RuntimeException:无法在线程内创建处理程序的→-2,5,未调用Looper.prepare()
负责此错误的代码部分是:
const permission = await ImagePicker.requestCameraPermissionsAsync();
if (permission.granted === false)
//Error handeling
console.log(permission);
let result = await ImagePicker.launchCameraAsync({
base64: false,
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
aspect: [3, 2],
quality: 1,
});
console.log(result);
if (!result.cancelled) {
console.log(result.uri);
setImages({ ...images, document: result.uri });
}我相信错误可能是由于与其他世博模块不兼容,但我不确定,因为我没有更新或改变我的应用程序中的模块,这里是我认为是相关模块的版本。
"expo": "~46.0.16",
"expo-image-picker": "~13.3.1",
"expo-updates": "~0.14.6",发布于 2022-11-16 01:31:15
我昨天还面临着同样的问题。当我清除应用程序的内存时,一切都解决了。如果它对你也有用的话,你可以试试。
https://stackoverflow.com/questions/74452419
复制相似问题