RC2 & Cordova Camera Plugin throws error on Android


#1

Using the Camera plugin with ionic native throws an error on android.

My environment:
Your system information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.2
Ionic CLI Version: 2.1.4
Ionic App Lib Version: 2.1.2
Ionic App Scripts Version: 0.0.42
ios-deploy version: 1.9.0
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v6.8.0
Xcode version: Xcode 8.1 Build version 8B62

Simple script to reproduce. Created a project with the blank template. My home.ts

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {Camera} from 'ionic-native';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})

export class HomePage {
  public myImage:string;
  constructor(public navCtrl: NavController) {

       this.myImage = "https://placehold.it/150x150";
  }

  public takePic(){

    Camera.getPicture({

            quality : 75,
            destinationType : Camera.DestinationType.DATA_URL,
            sourceType : Camera.PictureSourceType.CAMERA,
            allowEdit : false,
            encodingType: Camera.EncodingType.JPEG,
            targetWidth: 300,
            targetHeight: 300,
            saveToPhotoAlbum: true

    }).then( (imageData) => {

        this.myImage = "data:image/jpeg;base64," + imageData;

    }, (err) => {

        alert(err);
    });
  }
}

In template I just have a button calling the function and an image binded to the myImage var. In android emulator and on device alert(err); is called.

Created a demo repo here: https://github.com/florianbepunkt/ionic2-rc2-camera-issue

Also created an issue on github: https://github.com/driftyco/ionic-native/issues/782