Camara Nativa Ionic 3 Error: Illegal Argument Exception

0

Good afternoon, I want to use this plugin to take pictures, but when emulate it on my cell phone and inspecting its use, clicking on my button to capture the photo I get the following message and I have not been able to fix it, some help?

install it as the official page said:

ionic cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION="the app need the camera" --variable PHOTOLIBRARY_USAGE_DESCRIPTION="the app need the photolibrary"

npm install @ionic-native/camera --save

In my HTML code:

<button ion-button  (click)="sacarFoto()" color="reiterativa">
                    Tomar <br> Foto&nbsp;
                    <ion-icon name="ios-camera-outline" style="font-size:30px;"></ion-icon>
                </button>
                <img [src]="image" *ngIf="image" />

in TS:

import { Camera, CameraOptions } from '@ionic-native/camera';
.
.
constructor(private camera: Camera....){}
.
.
sacarFoto(){
    let options: CameraOptions = {
      destinationType: this.camera.DestinationType.DATA_URL,
      targetWidth: 1000,
      targetHeight: 1000,
      quality: 100,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE,
      saveToPhotoAlbum: true
    }
    this.camera.getPicture( options )
    .then(imageData => {
      this.image = 'data:image/jpeg;base64,' + imageData;
    })
    .catch(error =>{
      console.error( "error detalle: "+error );
    });
  }

Finally I can see on the screen what happens next to the catch:

error detalle: Illegal Argument Exception 

I emulate it in the following way with the cell phone connected via USB:

ionic cordova run android --prod

EDIT: I just tried generating the apk: ionic cordova build android --prod and there if you open the camera and you can take the photo, but I would like to do it with the phone connected through the emulation to see other details, since it only fails in the emulation from the browser (chrome)

    
asked by Kako 10.12.2017 в 08:45
source

1 answer

0

Unfortunately you can not see it from the emulator since it is a native plugin, this means that only from a real device can it be used. The only way to test it is with your cell phone or perhaps with a browser that is for web.

    
answered by 15.12.2017 в 02:50