I am using react-native-image-crop-picker in my react-native application and recording video from the camera in Android It is returning [Error: User cancelled image selection]
NOTE: It is working fine on Android 13 & 14 mobiles. But it is giving an error in Tab - Samsung Galaxy Tab A8 (Android 13).
react-native-image-crop-picker
Versions used
react-native-image-crop-picker v^0.40.2
react-native v0.72.0
react v18.2.0
Android v13
Platform - Android
Expected behaviour
When we record video using ImagePicker.openCamera recorder video path must be returned as it returns when the image is captured.
Actual behaviour
After the video is recorded and we click ok it gives [Error: User cancelled image selection]
Steps to reproduce
AndroidManifest.xml.
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
Sample code
recordVideo = async() => {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.CAMERA,
{
title: "App Camera Permission",
message:"App needs access to your camera ",
buttonNeutral: "Ask Me Later",
buttonNegative: "Cancel",
buttonPositive: "OK"
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
ImagePicker.openCamera({
mediaType:'video'
})
.then((image) => {
console.log(" Image ", image)
})
.catch((error) => {
if (error && error.code === 'E_PICKER_CANCELLED') {
return false;
}
})
} else {
console.log("Camera permission denied");
}
} catch (err) {
console.warn(err);
}
}
Uninstall using npm uninstall react-native-image-crop-picker and again install using npm i react-native-image-crop-picker and don't forget to add to android/app/src/main/AndroidManifest.xml.
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With