cordova plugin camera not capturing image resolveLocalFileSystemURL error on android 5
<p>I am trying to add an image from my image gallery in my ionic application using Google Nexus 5 but i keep running to the same error message </p>

<pre><code>W/System.err( 2544): java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
W/System.err( 2544):    at org.apache.cordova.file.ContentFilesystem.getFileMetadataForLocalURL(ContentFilesystem.java:130)
W/System.err( 2544):    at org.apache.cordova.file.Filesystem.exists(Filesystem.java:130)
W/System.err( 2544):    at org.apache.cordova.file.FileUtils.resolveLocalFileSystemURI(FileUtils.java:619)
W/System.err( 2544):    at org.apache.cordova.file.FileUtils.access$400(FileUtils.java:51)
W/System.err( 2544):    at org.apache.cordova.file.FileUtils$14.run(FileUtils.java:378)
W/System.err( 2544):    at org.apache.cordova.file.FileUtils$25.run(FileUtils.java:561)
W/System.err( 2544):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err( 2544):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err( 2544):    at java.lang.Thread.run(Thread.java:818)
</code></pre>

<p>My angularjs code </p>

<pre><code> var options = {
      destinationType : Camera.DestinationType.FILE_URI,
      sourceType : Camera.PictureSourceType.PHOTOLIBRARY,
      allowEdit : false,
      encodingType: Camera.EncodingType.JPEG,
      popoverOptions: CameraPopoverOptions,
      mediaType: Camera.MediaType.PICTURE,
      correctOrientation: true
    };

   // 3
    $cordovaCamera.getPicture(options).then(function(imageData) {
   // 4
      var imagetype;
      onImageSuccess(imageData);
      function onImageSuccess(fileURI) {
        createFileEntry(fileURI);
      }

      function createFileEntry(fileURI) {
        window.resolveLocalFileSystemURL(fileURI, copyFile, fail);
      }

       // 5
      function copyFile(fileEntry) {
        var name = fileEntry.fullPath.substr(fileEntry.fullPath.lastIndexOf('/') + 1);
        var newName = (new Date()).getTime() + name;
         halfthru(fileEntry, newName); //diff
         getImageType(fileEntry); //diff

      }

      function getImageType(fileEntry) { //diff
        var typeImage;
        $scope.$evalAsync(function() {
          fileEntry.file(function(file){
            typeImage= file.type;
            $scope.imagelist = typeImage;
            imagetype = typeImage;
          }, function(e){
          });
        })

      }

     function halfthru(fileEntry, newName) {
        window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(fileSystem2) {
          fileEntry.copyTo(
            fileSystem2,
            newName,
            onCopySuccess,
            fail
          );
        }, fail);
      }

      // 6
      function onCopySuccess(entry) {
          $scope.activeSlide = index;
          if(modalExists === false) {
            $ionicModal.fromTemplateUrl('image-modal.html', {
              scope: $scope,
            }).then(function(modal) {

              $scope.modal1 = modal;
              $scope.modal1.show();
              modalExists = true;
              $scope.$evalAsync($scope.images.push({file: entry.nativeURL, type: $scope.imagelist}));
              imagesModalCount =  $scope.images.length;
              attachedImageCount = $scope.imagesAttached.length;
            });
          }
          else {
            $scope.modal1.show();
            $scope.$evalAsync($scope.images.push({file: entry.nativeURL, type: $scope.imagelist}));
            imagesModalCount =  $scope.images.length;
            attachedImageCount  = $scope.imagesAttached.length;
          }

          $scope.$on('$destroy', function() {
            $scope.modal1.remove();
          });

      }

      function fail(error) {

      }
    }, function(err) {

    });
</code></pre>

<p>I know the issue has to do with cordova plugin file and some android 5 issues but how to i solve this? </p>