capacitor-plugins
capacitor-plugins copied to clipboard
bug(camera): Camera.requestPermissions() hangs on Android 33+
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
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 💙
@jcesarmobile @Ionitron added repo
Hello, our team is experiencing the same issue, is there any progress on the bug, just to know what to tell our users.
We are experiencing the same issue. Any updates?
@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.
Is it safe to use without requesting permissions to read from camera/gallery, I thought it should always ask the user.
Still not working on Android version 11, its not supported anymore?
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?
It still isn’t behaving correctly. Example:
const checkPermissionResponse = Camera.checkPermissions();
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, 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!
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.