Android Error - Access denied unable to save cropped image

Viewed 5484

I have an Ionic 5/Angular app that uses the Ionic Native Camera plugin to take pictures and crop the images. The functionality worked fine until I updated to Android 11 (using note 10 plus). After the update, the following error is thrown when cropping: unable to save cropped image - access denied.

TS code:

takePicture() {
    this.androidPermissions.requestPermissions([this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE, 
    this.androidPermissions.PERMISSION.WRITE_EXTERNAL_STORAGE]);

    const options: CameraOptions = {
      quality: 100,
      targetHeight: 1920,
      targetWidth: 1080,
      sourceType: 1, // CAMERA
      destinationType: 0, // DATA_URL
      encodingType: this.camera.EncodingType.JPEG,
      correctOrientation: true,
      allowEdit: true
    };

    this.camera.getPicture(options).then((imageData) => {
     // Persist image data
    });
  }

App works fine on other devices. Also checked that my app, Gallery app and Photo Editor app has storage and camera permissions. I can take the picture and the cropper opens - after tapping on Done the message "Access Denied" is displayed followed shortly after by "Unable to save cropped image".

Open camera

Crop image

Click done - Access denied error

Crop error

  1. What could be causing the error?
  2. How can I see what app is set as the default cropping app for the device?
  3. How can I clear/reset the default cropping app?

Note: I tested this on another device running Android 11 which resulted in the same error.

4 Answers

In my case, 'cropping image' caused this problem. So if you don't care about cropping, change 'allowEdit: true' to 'allowEdit: false'. Then the error will be removed. However, don't forget that you will not be able to crop a picture.

My best bet is, if you can, downgrading. It Did work last version, correct?

Related