Ionic 2 App closes after taking picture

On my devices, whenever I use the camera. Which is from:

import { Camera } from 'ionic-native';

my app shows a black screen then force closes. This happens when I’m using:

sourceType : Camera.PictureSourceType.CAMERA,

@trevaun23 … have you got solution to this problem ??

Do you have (public camera: Camera) set in your constructor. I’ve seen this issue occur when people have it set to private.

I’ve also seen this occur when trying to set saveToPhotoAlbum: true (or saveToAlbum) not sure of the exact syntax

This may be the result of memory issues too, which is a common problem with the Camera plugin.

Capacitor is introducing some things to fix this, but I’m not sure if they’re finished yet.

Yep. That’s another usual suspect. Not sure if reducing the target width / height or quality might be helpful in that case.

so i have to make it as a public camera:camera right ??..initially it is private…

Yeah, I’d give it a try at the least. It certainly won’t hurt. FYI, I’m pretty sure setting imports to private in your constructor is useless. That property gets squashed when the code gets javascripted, I believe.

But yeah, try out constructor(public camera: Camera)

And see what happens

no am using typescript.(ionic 3).and in my app camera plugin working properly for android 4.4 device but not work for android 5 version… for 6 it also work

Yeah, all that TypeScript turns into JavaScript when all is said and done. It’s complicated. I don’t understand the whole process but I think that private properties (in constructor only, private variables retain their private status) lose their private status.

Take it with a grain of salt though.

Strange it’s working on some versions. Makes me think @SigmundFroyd might have the right idea with memory issues. Again, nothing to lose by giving it a try

okay thanks for solution i will try

thanks @jaydz but your solution is not solve this problem…you have another solution ??

Unfortunately not. Sorry.

If this problem can be isolated to Android Oreo, read this. It’s a permission granularity problem.

@rapropos my device version is android 5 …will above solution solved my problem ?? becuase it is for android 8 version right ??

and android -v6 camera taking picture but not display image on screen it …and in android 5 …camera is not opening for taking picture