@capacitor/camera: Camera / Image Selector does not open up on Android 13+
Bug Report
Plugin(s)
@capacitor/camera 7.0.0
Capacitor Version
Latest Dependencies:
@capacitor/cli: 7.2.0
@capacitor/core: 7.2.0
@capacitor/android: 7.2.0
@capacitor/ios: 7.2.0
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/core: 7.1.0
@capacitor/android: 7.1.0
@capacitor/cli: 7.1.0
Platform(s)
@ionic/angular: 8.5.2
Android API 33 (Android 13) Android API 34 (Android 14) Android API 35 (Android 15)
Current Behavior
Previously, before and in Android 13, the Camera / Image Selector would open up in my projects. Users with Android 13 and newer are complaining that this is no longer the case. I confirmed it by running in the emulator.
My AndroidManifest.xml contains these permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
Expected Behavior
Camera / Image Selector opens up on Android 13+.
Code Reproduction
CAMERA:
await Camera.requestPermissions()
.then(async (permissions) => {
if (permissions.camera != "denied") {
await Camera.getPhoto(this.cameraOptions)
.then( (image: any) => {
resolve(image.webPath);
})
.catch(error => {
if (error.message != "User cancelled photos app") {
reject("camera/error");
}
});
}
else {
reject("media/permissions-not-granted");
}
})
.catch(error => reject("media/permissions-not-granted"));
PICTURE GALLERY:
await Camera.requestPermissions()
.then(async (permissions) => {
if (permissions.photos != "denied") {
await Camera.pickImages(this.galleryOptions)
.then(sel => {
resolve(sel.photos[0].webPath);
})
.catch(error => {
if (error.message != "No images picked") {
reject("gallery/error");
}
});
}
else {
reject("media/permissions-not-granted");
}
})
.catch(error => reject("media/permissions-not-granted"));
Additional Context
I managed to fix this by REMOVING the await Camera.requestPermissions() permission check, and instead calling await Camera.getPhoto() or await Camera.pickImages() directly. This no longer brings up the permission request, but it seems to be working: the camera and the picker open up (note: the needed permissions are set in the manifest).
I tested this on the emulator on API 31 to 36 and on a physical device with API 34. All are working now.
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.