# Having problem with ngCordova Camera Plugin

**URL:** <https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562>\
**Category:** cordova\
**Created:** [March 23, 2015, 8:48am UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562 "2015-03-23T08:48:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jariwalabhavesh](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@jariwalabhavesh](https://forum.ionicframework.com/u/jariwalabhavesh)\
**Post date:** [March 23, 2015, 8:48am UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/1 "2015-03-23T08:48:11Z")

</div>

Hi There,

I am trying to get pic from phone camera and store into phone gallery using ionic framework.

For that i am using [org.apache.cordova.camera](http://ngcordova.com/docs/plugins/camera/)

My application is working properly. It is able to take picture from camera and load into img tag on page.

I am only facing difficulty with the camera plugin option “ **saveToPhotoAlbum** ”.

when i make **saveToPhotoAlbum** to **False** then it is capturing image and i am getting image in the cache folder of application in android phone.

But when i make **saveToPhotoAlbum** to **true** then it is capturing image and storing it to gallary as well but also giving error in error callback that is **“Error Capturing Image”**. because of that i am unable to getting the path of captured image.

I am unable to find why i am getting this error. can any body help me to solve this problem.

My code is here:

**Index.html**

```
<div ng-controller="indexController">
    <ion-content>
            <div class="card">
                <div class="item item-divider">
                    Take a picture
                </div>
                <div class="item item-image">
                    <img id="imgbox" class="item" src="{{cameraService.cameraimage}}" style="height: 350px;"/>
                </div>
            </div>
    
            <div class="padding">
                <button class="button button-block button-positive" ng-click="cameraService.takePhoto()">
                    Take New Photo
                </button>
                <button class="button button-block button-positive" ng-click="cameraService.fetchPhoto()">
                    Get From Gallery
                </button>
            </div>
        </ion-content>
</div>

```

**CameraService.js**

```
 App.service('cameraService', function($cordovaCamera,$cordovaFile) {
        this.cameraimage;       

        this.getPhoto = function(SourceType) {
            var options = {
                quality: 50,
                destinationType: Camera.DestinationType.FILE_URI,
                sourceType: SourceType,
                saveToPhotoAlbum: true,
                encodingType: Camera.EncodingType.JPEG    
            };
    
            $cordovaCamera.getPicture(options).then(function(imageData) {
                console.log("img URI= " + imageData);
                var image = document.getElementById('imgbox');
                image.src = imageData;
            }, function(err) {
                 alert("Failed because: "+ err);
                console.log('Failed because: ' + err);
            });     
        };
           
        this.takePhoto = function(sourceType) {
            this.getPhoto(Camera.PictureSourceType.CAMERA);
        };
    
        this.fetchPhoto = function(SourceType) {
            this.getPhoto(Camera.PictureSourceType.SAVEDPHOTOALBUM);
        };
    });

```

**IndexConroller.js**

```
  App.controller('indexController', function($scope,cameraService) {
         $scope.cameraService=cameraService;
    });

```

---

<div class="post-metadata">

**Author:** ![jariwalabhavesh](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@jariwalabhavesh](https://forum.ionicframework.com/u/jariwalabhavesh)\
**Post date:** [March 24, 2015, 3:42am UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/2 "2015-03-24T03:42:32Z")

</div>

I had also test this code in ios and it working without any error. i don’t know what is the problem with android.

---

<div class="post-metadata">

**Author:** ![bengtler](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bengtler/32/98565_2.png) [@bengtler](https://forum.ionicframework.com/u/bengtler)\
**Post date:** [March 24, 2015, 6:49am UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/3 "2015-03-24T06:49:55Z")

</div>

Is you app closed after you are taking the photo?

Android sometimes close the app, that opens the camera to free memory for the camera.  
So in somecases my Moto G and G (2. edition) gets closed when i open the camera.

Do not recognized this behavior if i use saveToPhotoAlbum true.  
Is you app still open afterwards or does it a restart?

Greets.

---

<div class="post-metadata">

**Author:** ![jariwalabhavesh](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@jariwalabhavesh](https://forum.ionicframework.com/u/jariwalabhavesh)\
**Post date:** [March 24, 2015, 8:18am UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/4 "2015-03-24T08:18:15Z")

</div>

No application is not closed after capturing image.  
It is just giving error “Error Capturing Image” but actually image is already stored in gallery.

---

<div class="post-metadata">

**Author:** ![robotvert](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/robotvert/32/73533_2.png) [@robotvert](https://forum.ionicframework.com/u/robotvert)\
**Post date:** [March 31, 2015, 3:06pm UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/5 "2015-03-31T15:06:03Z")

</div>

FWIW I had the exact same issue with version 0.3.6 of the plugin (the latest one).  
Downgrading to 0.3.5 fixed the issue for me.

---

<div class="post-metadata">

**Author:** ![ghz](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ghz/32/80726_2.png) [@ghz](https://forum.ionicframework.com/u/ghz)\
**Post date:** [April 1, 2015, 12:26pm UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/6 "2015-04-01T12:26:23Z")

</div>

Thx ! It works again with the downgrade.

---

<div class="post-metadata">

**Author:** ![jariwalabhavesh](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@jariwalabhavesh](https://forum.ionicframework.com/u/jariwalabhavesh)\
**Post date:** [April 3, 2015, 3:37am UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/7 "2015-04-03T03:37:34Z")

</div>

Thanks it also fix for me

---

<div class="post-metadata">

**Author:** ![abhi1436](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@abhi1436](https://forum.ionicframework.com/u/abhi1436)\
**Post date:** [April 23, 2015, 7:03am UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/8 "2015-04-23T07:03:27Z")

</div>

hie…  
i am new to ionic . i amd using ng cordova camera and i want to set the image name clicked by camera. is dere any way ??? please help me out…  
if is dere any example . please share

---

<div class="post-metadata">

**Author:** ![skyrocket777](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/skyrocket777/32/80521_2.png) [@skyrocket777](https://forum.ionicframework.com/u/skyrocket777)\
**Post date:** [June 9, 2015, 3:46pm UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/9 "2015-06-09T15:46:13Z")

</div>

In my case I have this problem increasing either the quality or width and height of the picture. I just can use 20 of quality as maximun, very poor. I downgrade the pluging and still have the problem. Anyone can help me? thank you

---

<div class="post-metadata">

**Author:** ![kmraditya](https://avatars.discourse-cdn.com/v4/letter/k/4bbf92/32.png) [@kmraditya](https://forum.ionicframework.com/u/kmraditya)\
**Post date:** [December 19, 2015, 3:08pm UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/10 "2015-12-19T15:08:54Z")

</div>

**@skyrocket777** in your camera plugin code add permission for allow edit as mentioned below

navigator.camera.getPicture(onSuccess, onFail, {  
quality : 20,  
sourceType : Camera.PictureSourceType.CAMERA,  
destinationType : Camera.DestinationType.FILE\_URI,  
saveToPhotoAlbum: true,  
encodingType: Camera.EncodingType.JPEG,  
correctOrientation:true,  
allowEdit: true  
});

---

<div class="post-metadata">

**Author:** ![premkumar1528](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@premkumar1528](https://forum.ionicframework.com/u/premkumar1528)\
**Post date:** [May 24, 2017, 6:05am UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/11 "2017-05-24T06:05:47Z")

</div>

I am also getting error, i have checked with all device in android,

also checked uninstall and re-install the camera plugin, kindly help me

this the error :-

05-24 11:37:12.593: E/PluginManager(13986): Uncaught exception from plugin  
05-24 11:37:12.593: E/PluginManager(13986): java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)’ on a null object reference  
05-24 11:37:12.593: E/PluginManager(13986): at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:560)  
05-24 11:37:12.593: E/PluginManager(13986): at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:534)  
05-24 11:37:12.593: E/PluginManager(13986): at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:376)  
05-24 11:37:12.593: E/PluginManager(13986): at org.apache.cordova.camera.CameraLauncher.takePicture(CameraLauncher.java:295)  
05-24 11:37:12.593: E/PluginManager(13986): at org.apache.cordova.camera.CameraLauncher.callTakePicture(CameraLauncher.java:275)  
05-24 11:37:12.593: E/PluginManager(13986): at org.apache.cordova.camera.CameraLauncher.execute(CameraLauncher.java:184)  
05-24 11:37:12.593: E/PluginManager(13986): at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)  
05-24 11:37:12.593: E/PluginManager(13986): at org.apache.cordova.PluginManager.exec(PluginManager.java:132)  
05-24 11:37:12.593: E/PluginManager(13986): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:57)  
05-24 11:37:12.593: E/PluginManager(13986): at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)  
05-24 11:37:12.593: E/PluginManager(13986): at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)  
05-24 11:37:12.593: E/PluginManager(13986): at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:41)  
05-24 11:37:12.593: E/PluginManager(13986): at android.os.Handler.dispatchMessage(Handler.java:111)  
05-24 11:37:12.593: E/PluginManager(13986): at android.os.Looper.loop(Looper.java:207)  
05-24 11:37:12.593: E/PluginManager(13986): at android.os.HandlerThread.run(HandlerThread.java:61)  
05-24 11:37:12.606: D/PerfServiceManager(941): [PerfService] MESSAGE\_TIMEOUT:103

My plugins --v:-  
“cordova-plugin-camera”: “^2.4.1”,  
“cordova-plugin-compat”: “^1.1.0”,

---

<div class="post-metadata">

**Author:** ![prashasti](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@prashasti](https://forum.ionicframework.com/u/prashasti)\
**Post date:** [October 12, 2017, 6:47am UTC](https://forum.ionicframework.com/t/having-problem-with-ngcordova-camera-plugin/19562/12 "2017-10-12T06:47:48Z")

</div>

Hi , did you found any solution for this error?  
I too have “cordova-plugin-camera”: “^2.4.1”,
