capacitor-plugins icon indicating copy to clipboard operation
capacitor-plugins copied to clipboard

bug(camera): Camera.requestPermissions() hangs on Android 33+

Open stefanMinch3v opened this issue 1 year ago • 6 comments

Capacitor Version

6

Other API Details

No response

Platforms Affected

  • [ ] iOS
  • [X] Android
  • [ ] Web

Current Behavior

When I click the button to pick an image from the gallery nothing happens

Expected Behavior

When i click the button to pick an image from the gallery it shows a pop-up to allow reading images and then select the image

Project Reproduction

https://github.com/stefanMinch3v/capacitor-bug-image-gallery/tree/main

Additional Information

On capacitor 5 the code below works as expected. It requests permission to read from gallery and then shows the gallery to pick an image. With capacitor 6, on button click nothing happens

With only these 2 permissions in the AndroidManifest.xml file uses-permission android:name="android.permission.READ_MEDIA_IMAGES" uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"

Android version tested - 12 (works here), 13 (not working) and 14 (not working)

`async selectImage(): Promise {

try {
  await Camera.requestPermissions();
} catch {
  // do nothing
}

let img: Photo = null;

try {
  img = await Camera.getPhoto({
    quality: 90,
    allowEditing: false,
    resultType: CameraResultType.Base64,
    source: CameraSource.Photos
  });
} catch {
  // cancel image from gallery
}

if (img) {
 // continue the flow below
}

}`

Any idea how should I proceed here, do I need to add some extra code or permissions to the manifest file? Thank you

stefanMinch3v avatar Jun 08 '24 18:06 stefanMinch3v