cordova-plugin-camera icon indicating copy to clipboard operation
cordova-plugin-camera copied to clipboard

Attempt to invoke virtual method 'boolean java.io.File.mkdirs()' on a null object reference

Open EvilShok opened this issue 5 years ago • 12 comments

the problem occurs in android when the phone have the sd shared has a internal memory this is the options constant that i use const options: CameraOptions = { sourceType:this.camera.PictureSourceType.CAMERA, quality: 50, destinationType: this.camera.DestinationType.DATA_URL, encodingType: this.camera.EncodingType.JPEG, mediaType: this.camera.MediaType.PICTURE, correctOrientation: true, saveToPhotoAlbum:true } this work fine in phones that no have the sd shared

EvilShok avatar Jan 13 '19 22:01 EvilShok

i know one of our users, who have the same issue. i know the user use a sd card on his device.

maerlynflagg avatar Feb 19 '19 07:02 maerlynflagg

I don't think this is SD Card problem, we are getting same error without sd card in device. @EvilShok please share your code if it got worked

KirankumarDafda avatar Jul 06 '19 09:07 KirankumarDafda

Is this reproducible in a new, plain Cordova app? A minimal reproduction repository would really help to debug and later fix this issue. More information on how to create one: https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md

janpio avatar Jul 06 '19 10:07 janpio

Actaully I am working with IONIC application and using camera + barcode scanner cordova plugins, where barcode reader working absolutely fine. Scanner is opens camera scan any barcode and generate response, but same is not working for camera. So I'll try reproducing the same app with current issue and i'll update you.

KirankumarDafda avatar Jul 08 '19 09:07 KirankumarDafda

Yeah, an Ionic app is a good first step as well - but as it adds so much code in beteween we always have to look at a plain Cordova reproduction before fixing anything. The problem could be in the Ionic Native wrapper for example.

janpio avatar Jul 08 '19 09:07 janpio

I am still facing the issue after many tries, I don't know if there is any specific plugin that creates problem. As the same code working fine in iOS, So below are my details of project like error screenshot, package.json and config.xml. So please have a look once and let me know if require anything else from me.

Screenshot_20190712-112054

This is my package.json file

 {
    "name": "PROJECT_NAME",
    "version": "1.0.0",
    "author": "Ionic Framework",
    "homepage": "https://ionicframework.com/",
    "scripts": {
      "ng": "ng",
      "start": "ng serve",
      "build": "ng build",
      "test": "ng test",
      "lint": "ng lint",
      "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
      "@angular/common": "^7.2.2",
      "@angular/core": "^7.2.2",
      "@angular/forms": "^7.2.2",
      "@angular/http": "^7.2.2",
      "@angular/platform-browser": "^7.2.2",
      "@angular/platform-browser-dynamic": "^7.2.2",
      "@angular/router": "^7.2.2",
      "@ionic-native/action-sheet": "^5.9.0",
      "@ionic-native/barcode-scanner": "^5.9.0",
      "@ionic-native/camera": "^5.9.0",
      "@ionic-native/camera-preview": "^5.9.0",
      "@ionic-native/core": "^5.8.0",
      "@ionic-native/crop": "^5.9.0",
      "@ionic-native/date-picker": "^5.4.0",
      "@ionic-native/file": "^5.9.0",
      "@ionic-native/file-path": "^5.9.0",
      "@ionic-native/http": "^5.5.1",
      "@ionic-native/image-picker": "^5.9.0",
      "@ionic-native/photo-viewer": "^5.4.0",
      "@ionic-native/sms": "^5.5.0",
      "@ionic-native/splash-screen": "^5.0.0",
      "@ionic-native/status-bar": "^5.0.0",
      "@ionic/angular": "^4.1.0",
      "@mobiscroll/angular": "https://npm.mobiscroll.com/@mobiscroll/angular-trial/-/angular-trial-4.6.2.tgz",
      "com-sarriaroman-photoviewer": "^1.2.2",
      "cordova-android": "^8.0.0",
      "cordova-browser": "6.0.0",
      "cordova-ios": "5.0.1",
      "cordova-plugin-actionsheet": "^2.3.3",
      "cordova-plugin-add-swift-support": "^2.0.2",
      "cordova-plugin-advanced-http": "^2.0.9",
      "cordova-plugin-camera": "^4.0.3",
      "cordova-plugin-camera-preview": "^0.11.0",
      "cordova-plugin-crop": "^0.4.0",
      "cordova-plugin-datepicker": "^0.9.3",
      "cordova-plugin-device": "^2.0.2",
      "cordova-plugin-file": "^6.0.1",
      "cordova-plugin-file-transfer": "^1.7.1",
      "cordova-plugin-filepath": "^1.5.5",
      "cordova-plugin-ionic-keyboard": "^2.1.3",
      "cordova-plugin-ionic-webview": "^3.1.2",
      "cordova-plugin-ios-camera-permissions": "^1.2.0",
      "cordova-plugin-splashscreen": "^5.0.2",
      "cordova-plugin-statusbar": "^2.4.2",
      "cordova-plugin-telerik-imagepicker": "^2.3.2",
      "cordova-plugin-whitelist": "^1.3.3",
      "cordova-sms-plugin": "^1.0.0",
      "core-js": "^2.5.4",
      "daterangepicker": "^3.0.3",
      "ion2-calendar": "^3.0.0-rc.0",
      "ionic4-rating": "^1.0.9",
      "moment": "^2.24.0",
      "phonegap-plugin-barcodescanner": "^8.1.0",
      "rxjs": "~6.3.3",
      "rxjs-compat": "^6.4.0",
      "sweetalert2": "^8.8.5",
      "zone.js": "~0.8.29"
    },
    "devDependencies": {
      "@angular-devkit/architect": "~0.12.3",
      "@angular-devkit/build-angular": "~0.13.0",
      "@angular-devkit/core": "~7.2.3",
      "@angular-devkit/schematics": "~7.2.3",
      "@angular/cli": "~7.3.1",
      "@angular/compiler": "~7.2.2",
      "@angular/compiler-cli": "~7.2.2",
      "@angular/language-service": "~7.2.2",
      "@ionic/angular-toolkit": "~1.4.0",
      "@types/node": "~10.14.2",
      "@types/jasmine": "~2.8.8",
      "@types/jasminewd2": "~2.0.3",
      "codelyzer": "~4.5.0",
      "jasmine-core": "~2.99.1",
      "jasmine-spec-reporter": "~4.2.1",
      "karma": "~3.1.4",
      "karma-chrome-launcher": "~2.2.0",
      "karma-coverage-istanbul-reporter": "~2.0.1",
      "karma-jasmine": "~1.1.2",
      "karma-jasmine-html-reporter": "^0.2.2",
      "protractor": "~5.4.0",
      "ts-node": "~8.0.0",
      "tslint": "~5.12.0",
      "typescript": "~3.1.6"
    },
    "description": "An Ionic project",
    "cordova": {
      "plugins": {
        "cordova-plugin-whitelist": {},
        "cordova-plugin-statusbar": {},
        "cordova-plugin-device": {},
        "cordova-plugin-splashscreen": {},
        "cordova-plugin-ionic-webview": {
          "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
        },
        "cordova-plugin-ionic-keyboard": {},
        "cordova-plugin-datepicker": {},
        "com-sarriaroman-photoviewer": {},
        "cordova-sms-plugin": {},
        "cordova-plugin-advanced-http": {},
        "phonegap-plugin-barcodescanner": {
          "ANDROID_SUPPORT_V4_VERSION": "27.+"
        },
        "cordova-plugin-file": {},
        "cordova-plugin-filepath": {},
        "cordova-plugin-actionsheet": {},
        "cordova-plugin-camera-preview": {
          "ANDROID_SUPPORT_LIBRARY_VERSION": "26+"
        },
        "cordova-plugin-ios-camera-permissions": {
          "CAMERA_USAGE_DESCRIPTION": "This app needs camera access",
          "MICROPHONE_USAGE_DESCRIPTION": "This app needs microphone access",
          "PHOTOLIBRARY_ADD_USAGE_DESCRIPTION": "This app needs write-access to photo library",
          "PHOTOLIBRARY_USAGE_DESCRIPTION": "This app needs read/write-access photo library access"
        },
        "cordova-plugin-crop": {},
        "cordova-plugin-file-transfer": {},
        "cordova-plugin-camera": {},
        "cordova-plugin-telerik-imagepicker": {
          "PHOTO_LIBRARY_USAGE_DESCRIPTION": " "
        }
      },
      "platforms": [
        "ios",
        "android"
      ]
    }
  }

Here is config.xml building right now.

<?xml version='1.0' encoding='utf-8'?>
<widget id="PACKAGE_NAME_HERE" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>PROJECT_NAME</name>
    <description>An awesome Ionic/Cordova app.</description>
    <author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="ScrollEnabled" value="false" />
    <preference name="android-minSdkVersion" value="19" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="5000" />
    <preference name="ShowSplashScreenSpinner" value="false" />
    <preference name="orientation" value="portrait" />
    <preference name="AndroidPersistentFileLocation" value="Compatibility" />
    <platform name="android">
        <!-- All icon and splash sources here -->
        <edit-config file="AndroidManifest.xml" mode="merge" target="application">
            <application android:usesCleartextTraffic="true" />
        </edit-config>
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
       <!-- All icon and splash sources here -->
    </platform>
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-statusbar" spec="^2.4.2" />
    <plugin name="cordova-plugin-device" spec="^2.0.2" />
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
    <plugin name="cordova-plugin-ionic-webview" spec="^3.1.2">
        <variable name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" value="27.+" />
    </plugin>
    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.1.3" />
    <plugin name="cordova-plugin-datepicker" spec="^0.9.3" />
    <plugin name="com-sarriaroman-photoviewer" spec="^1.2.2" />
    <plugin name="cordova-sms-plugin" spec="^1.0.0" />
    <plugin name="cordova-plugin-advanced-http" spec="^2.0.9" />
</widget>

KirankumarDafda avatar Jul 12 '19 05:07 KirankumarDafda

As I wrote above, to actually be able to isolate this we need to know if this also happens in a new, plain Cordova app created with cordova create MyApp. We don't develop Ionic, Angular or Ionic Native which could all be the reason for this problem. So we have to pinpoint it to Cordova first - see https://github.com/apache/cordova-contribute/blob/master/create-reproduction.md for instructions.

janpio avatar Jul 12 '19 11:07 janpio

Sorry for late reply, As I was trying to solve the issue. And that was my IONIC project so tried to solve problem with that platform.

Finally solved the problem, Created new project as reproduction, I removed some plugins like camera-preview,camera-permission & image-picker. I am still not sure what that error exactly means. So I am sharing new package.json here. Hope this help others too.

  {
    "name": "PROJECT_NAME",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "https://ionicframework.com/",
    "scripts": {
      "ng": "ng",
      "start": "ng serve",
      "build": "ng build",
      "test": "ng test",
      "lint": "ng lint",
      "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
      "@angular/common": "^7.2.2",
      "@angular/core": "^7.2.2",
      "@angular/forms": "^7.2.2",
      "@angular/http": "^7.2.2",
      "@angular/platform-browser": "^7.2.2",
      "@angular/platform-browser-dynamic": "^7.2.2",
      "@angular/router": "^7.2.2",
      "@ionic-native/barcode-scanner": "^5.10.0",
      "@ionic-native/camera": "^5.10.0",
      "@ionic-native/core": "^5.0.0",
      "@ionic-native/file": "^5.10.0",
      "@ionic-native/file-path": "^5.10.0",
      "@ionic-native/http": "^5.10.0",
      "@ionic-native/photo-viewer": "^5.10.0",
      "@ionic-native/splash-screen": "^5.10.0",
      "@ionic-native/status-bar": "^5.0.0",
      "@ionic/angular": "^4.1.0",
      "com-sarriaroman-photoviewer": "1.2.3",
      "cordova-android": "8.0.0",
      "cordova-ios": "5.0.1",
      "cordova-plugin-advanced-http": "2.1.1",
      "cordova-plugin-camera": "4.1.0",
      "cordova-plugin-device": "^2.0.2",
      "cordova-plugin-file": "6.0.2",
      "cordova-plugin-filepath": "1.5.5",
      "cordova-plugin-ionic-keyboard": "^2.1.3",
      "cordova-plugin-ionic-webview": "^4.1.1",
      "cordova-plugin-splashscreen": "^5.0.2",
      "cordova-plugin-statusbar": "^2.4.2",
      "cordova-plugin-whitelist": "^1.3.3",
      "core-js": "^2.5.4",
      "ion2-calendar": "^2.2.0",
      "ionic-angular": "^3.9.8",
      "ionic4-rating": "^1.0.9",
      "moment": "^2.24.0",
      "phonegap-plugin-barcodescanner": "8.1.0",
      "rxjs": "~6.5.1",
      "rxjs-compat": "^6.5.2",
      "sweetalert2": "^8.13.6",
      "tslib": "^1.9.0",
      "zone.js": "~0.8.29"
    },
    "devDependencies": {
      "@angular-devkit/architect": "~0.13.8",
      "@angular-devkit/build-angular": "~0.13.8",
      "@angular-devkit/core": "~7.3.8",
      "@angular-devkit/schematics": "~7.3.8",
      "@angular/cli": "~7.3.8",
      "@angular/compiler": "~7.2.2",
      "@angular/compiler-cli": "~7.2.2",
      "@angular/language-service": "~7.2.2",
      "@ionic/angular-toolkit": "~1.5.1",
      "@types/node": "~12.0.0",
      "@types/jasmine": "~2.8.8",
      "@types/jasminewd2": "~2.0.3",
      "codelyzer": "~4.5.0",
      "jasmine-core": "~2.99.1",
      "jasmine-spec-reporter": "~4.2.1",
      "karma": "~4.1.0",
      "karma-chrome-launcher": "~2.2.0",
      "karma-coverage-istanbul-reporter": "~2.0.1",
      "karma-jasmine": "~1.1.2",
      "karma-jasmine-html-reporter": "^0.2.2",
      "protractor": "~5.4.0",
      "ts-node": "~8.3.0",
      "tslint": "~5.17.0",
      "typescript": "~3.1.6"
    },
    "description": "An Ionic project",
    "cordova": {
      "plugins": {
        "cordova-plugin-whitelist": {},
        "cordova-plugin-statusbar": {},
        "cordova-plugin-device": {},
        "cordova-plugin-splashscreen": {},
        "cordova-plugin-ionic-webview": {
          "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
        },
        "cordova-plugin-ionic-keyboard": {},
        "cordova-plugin-camera": {
          "ANDROID_SUPPORT_V4_VERSION": "27.+"
        },
        "cordova-plugin-file": {},
        "cordova-plugin-filepath": {},
        "com-sarriaroman-photoviewer": {},
        "cordova-plugin-advanced-http": {},
        "phonegap-plugin-barcodescanner": {
          "ANDROID_SUPPORT_V4_VERSION": "27.+"
        }
      },
      "platforms": [
        "android",
        "ios"
      ]
    }
  }

KirankumarDafda avatar Jul 18 '19 12:07 KirankumarDafda

I had this issue. I uninstalled the platform and re-installed it and everything works.

PostImpatica avatar Nov 08 '19 15:11 PostImpatica

I add Filepath plugin and work fine

tinoteam avatar May 07 '20 07:05 tinoteam

I have this issue for the camera on any Android API other than R. The image PHOTOLIBRARY source works fine, but the CAMERA source type seems to only work on API R. Not sure where to begin to fix this issue so any help would be appreciated

EStone55 avatar Jul 24 '20 14:07 EStone55

i have this issue too

shoerofi avatar Nov 24 '20 06:11 shoerofi