App stops after Camera Usage Ionic-Native

In my app takePicture() fxn is there to initate camera and save the image but…when i click ok after the picture preview the app is getting stopped.



      const options: CameraOptions = {
        quality: 100,
         this.base64Image = 'data:image/jpeg;base64,'+imageData;
        alert("EROOR IN SAVING PC");

And in html the fxn is called.

Can anyone tell what may be the issue here???

Are you using
What platform? What Ionic version (ionic infofrom CLI please)?


Have a look also at:

DATA_URL: Return base64 encoded string. DATA_URL can be very memory intensive and cause app crashes or out of memory errors. Use FILE_URI or NATIVE_URI if possible.

It looks like if you use DATA URL your device might not be able to handle it and it crashes for that reason.

You should use platform to detect if its android or iOS, then use FILE_URI for android and NATIVE_URI for iOS.

Hope it helps!

1 Like

@El_Pollito_Pio - this doesn’t work for me. I still keep getting “Unfortunately, MyApp has stopped”. Is there anything else I could try?


Are you by chance creating the function before you declare camera? I.e., above the constructor? Is the camera set to private as opposed to public?
Just a couple of maybes

Hey @jaydz,

Thanks for the reply. So I changed private to public and DATA_URI to FILE_URI, and that seemed to clear things up a bit. The app doesn’t crash anymore. So it is using lesser memory.

However, I need to upload the image I take to an external service using a POST request, and therefore DATA_URI (base64 string of the image) is the only way forward. Is there any chance I could continue using DATA_URI and still not use more than the memory allotted to the app?


Might seem like a silly question, but have you tried just changing private to public and uploading DATA_URI?

If not, try it. Take the scientific method approach and eliminate possibilities 1 at a time.

If you have tried it and it’s crashing your app still, it’s beyond my scope of knowledge. I’m not sure.

Unless there’s some other reason that DATA_URI can’t be used in your scenario and I’m just unaware or not thinking of it of course

1 Like

@jaydz, I used the scientific method alright :smile:

It seems to be a problem during development, but it previously worked as a full app (with the apk). Hopefully it will work once I publish it.

1 Like

Happy to hear it! Good luck!!