IONIC + cordova camera crashing on android


I am running an IONIC app using the camera. It works fine on more powerful devices but crashes the app on lower quality devices. My research tells me that the phone closes the app once it leaves to open the camera to save memory. I have reduced the size and quality of the image but it still crashes.

The plugin above is a proposed solution that stops the app from closing. But I cant get it to work and I am wondering how it will work with injecting it into IONIC.

So my question is; are there any working solutions to this problem where I dont have to fork my code and will run on IOS and android.

var options = {
                        quality: 50,
                        destinationType: Camera.DestinationType.DATA_URL,
                        sourceType: Camera.PictureSourceType.CAMERA,
                        allowEdit: true,
                        encodingType: Camera.EncodingType.JPEG,
                        correctOrientation: true,
                        targetWidth: 200,
                        targetHeight: 200,
                        popoverOptions: CameraPopoverOptions,
                        saveToPhotoAlbum: false
                    $ionicPlatform.ready(function ()
                        $cordovaCamera.getPicture(options).then(function (imageURI) {
                            return true;

                        }, function (err) {
                            var Popup = $ionicPopup.alert({
                                title: 'Error!',
                                template: err

This is the code I am using.



Put the console.log(JSON.stringify(options)); right after defining the ‘options’. I was facing similar problem and then I’ve noticed that destinationType was undefined which leads to a json similar to this:

   "quality" : 80,
   "sourceType" : 1,
   "allowEdit" : false,
   "encodingType" : 0,
   "saveToPhotoAlbum" : true

without the destinationType value. That crashed my application.

Answered By – Paulo Henrique Queiroz

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published