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

@capacitor/camera: Camera / Image Selector does not open up on Android 13+

Open NorthFred opened this issue 9 months ago • 1 comments

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

NorthFred avatar Apr 02 '25 14:04 NorthFred

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.

NorthFred avatar Apr 04 '25 15:04 NorthFred

Hey @NorthFred, 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

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 Aug 23 '25 12:08 ionitron-bot[bot]