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

This issue needs more information before it can be addressed. In particular, the reporter needs to provide a minimal sample app that demonstrates the issue. If no sample app is provided within 15 days, the issue will be closed. Please see the Contributing Guide for how to create a Sample App. Thanks! Ionitron 💙

ionitron-bot[bot] avatar Jun 10 '24 08:06 ionitron-bot[bot]

@jcesarmobile @Ionitron added repo

stefanMinch3v avatar Jun 11 '24 11:06 stefanMinch3v

Hello, our team is experiencing the same issue, is there any progress on the bug, just to know what to tell our users.

botrot avatar Jun 17 '24 07:06 botrot

We are experiencing the same issue. Any updates?

Lasseroenn avatar Jun 17 '24 08:06 Lasseroenn

@capacitor/camera 6 no longer requires permissions for picking pictures, see the breaking changes section of Capacitor 6 upgrade guide for Camera plugin https://capacitorjs.com/docs/updating/6-0#camera

So if you remove the await Camera.requestPermissions(); the picker will work.

But the Camera.requestPermissions(); should not hang on Android 33+, that should be fixed.

jcesarmobile avatar Jun 21 '24 11:06 jcesarmobile

Is it safe to use without requesting permissions to read from camera/gallery, I thought it should always ask the user.

botrot avatar Jun 24 '24 09:06 botrot

Hey everyone, this issue was fixed in camera plugin version 7.0.2.

Closing this issue. Thank you!

OS-pedrogustavobilro avatar Aug 08 '25 11:08 OS-pedrogustavobilro

Still not working on Android version 11, its not supported anymore?

LukasGrubis avatar Aug 19 '25 05:08 LukasGrubis

Hey @LukasGrubis, on my end I'm not having any issues with Camera.requestPermissions() on the latest version, including on Android 11, can you describe what problem you are experiencing?

OS-pedrogustavobilro avatar Aug 20 '25 17:08 OS-pedrogustavobilro

It still isn’t behaving correctly. Example:

const checkPermissionResponse = Camera.checkPermissions();
Image

Even when permissions are already granted, await Camera.requestPermissions({ permissions: ['photos'] }) should at least return the current status and not hang, blocking any subsequent code.

LukasGrubis avatar Sep 01 '25 05:09 LukasGrubis

@LukasGrubis, I am not able to reproduce what you are mentioning on any Android version with the latest version of the Camera Plugin and Capacitor 7. It could be you're experiencing a different problem.

I recommend opening a new issue with additional details.

Thanks!

OS-pedrogustavobilro avatar Sep 01 '25 08:09 OS-pedrogustavobilro

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of the plugin, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Sep 16 '25 08:09 ionitron-bot[bot]