Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-13773

camera.getPicture returns error code 20

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • None
    • None
    • cordova-plugin-camera
    • None
    • Android platform

    Description

      A call to `camera.getPicture` returns an error code of "20". This occurs on the Android platform. Things work fine on the browser platform.

      This error started suddenly a few days ago, and I cannot identify anything specific I did that might have caused it.

      It's very hard for me to present a reproducible case, since this is occurring in the context of large app, but I will try to reproduce in a sample app if there's no alternative. Meanwhile, I'm posting this issue in the hope that someone might know what an error 20 is supposed to mean.

      In case it matters, it strikes me as odd that the device is not asking me for access for the camera when I install the app, nor when I try to take the first picture.

      This happens on different devices, including Nougat and Oreo. It happens with different versions of the camera plugins. What is especially puzzling to me is that it happens with a build of my app from a version three months ago, even though that application works fine in the field.

      cordova-android version is 6.2.1. Cordova CLI version is 8.0.0.

      Here is some relevant code:

      function getPicture(cameraOptions: CameraOptions): Promise<string> {
        const {camera} = navigator;
      
        if (!camera) throw new Error("missing camera in cordova-plugin-camera.util");
      
        return new Promise((resolve, reject) => camera.getPicture(resolve, reject, cameraOptions));
      }
      
        // Get a picture from the camera, returning a promise for the URL on the device.
        private async getPictureCordova(library): Promise<string> {
          const destinationType = isPlatformWindows() ? Camera.DestinationType.DATA_URL : Camera.DestinationType.FILE_URI;
          const sourceType = library ? Camera.PictureSourceType.PHOTOLIBRARY : Camera.PictureSourceType.CAMERA;
          const cameraOptions: CameraOptions = {
            quality: 50,
            destinationType,
            sourceType,
            allowEdit : false,
            targetWidth: 1280,
            //      targetHeight: 960,
            correctOrientation: true,
            saveToPhotoAlbum: false,
            mediaType: Camera.MediaType.PICTURE,   // applies only in case of library
          };
      
          this.reset();
      
          return await getPicture(cameraOptions);
        }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            torazaburo Bob Myers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: