Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Record Video from react-native-image-crop-picker not working in android 13 - Tab (Samsung Galaxy Tab A8)

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

  1. Open Camera.
  2. Record the Video and click OK.
  3. Then we must get the recorded video path but it returns an error [Error: User cancelled image selection].

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);
  }
}
like image 227
Pratap Penmetsa Avatar asked Dec 06 '25 13:12

Pratap Penmetsa


1 Answers

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"/> 
like image 78
Pratik Prakash Bindage Avatar answered Dec 08 '25 03:12

Pratik Prakash Bindage



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!