apache / cordova-plugin-camera

Apache Cordova Plugin camera
https://cordova.apache.org/
Apache License 2.0
964 stars 1.54k forks source link

Opening camera Illegal Argument Exception since 4.2.0 | ANDROID #601

Closed simetin closed 4 years ago

simetin commented 4 years ago

Since updated to V4.2.0 yesterday, when I run the getPicture function I get the error "Illegal Argument Exception". The error is only happening on Android.

Cordova info output:
cordova-lib@9.0.1 with:
  cordova-common@3.2.1
  cordova-create@2.0.0
  cordova-fetch@2.0.1
  cordova-serve@3.0.0

Environment: 
  OS: darwin
  Node: v12.14.1
  npm: 6.13.4

Plugins:
  com.googlemaps.ios
  cordova-open-native-settings
  cordova-plugin-badge
  cordova-plugin-camera
  cordova-plugin-device
  cordova-plugin-facebook4
  cordova-plugin-file
  cordova-plugin-file-transfer
  cordova-plugin-geolocation
  cordova-plugin-globalization
  cordova-plugin-googlemaps
  cordova-plugin-inappbrowser
  cordova-plugin-ionic-keyboard
  cordova-plugin-ionic-webview
  cordova-plugin-media-capture
  cordova-plugin-nativestorage
  cordova-plugin-network-information
  cordova-plugin-screen-orientation
  cordova-plugin-splashscreen
  cordova-plugin-statusbar
  cordova-plugin-telerik-imagepicker
  cordova-plugin-video-editor
  cordova-plugin-whitelist
  cordova-plugin-x-socialsharing
  cordova.plugins.diagnostic
  es6-promise-plugin
  onesignal-cordova-plugin

Android platform:
  ERROR: android: Command failed with exit code ENOENT

iOS platform:
  Xcode 11.4
  Build version 11E146

config.xml <<EOF
<?xml version='1.0' encoding='utf-8'?>
<widget id="" version="2.0.11" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <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="3000" />
    <preference name="AllowInlineMediaPlayback" value="true" />
    <platform name="android">
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
            <application android:networkSecurityConfig="@xml/network_security_config" />
        </edit-config>
        <resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
        <allow-intent href="market:*" />

    </platform>
    <platform name="ios">

    </platform>
    <allow-navigation href="*" />
    <plugin name="cordova-plugin-nativestorage" spec="~2.3.2" />
    <plugin name="cordova-open-native-settings" spec="~1.5.2" />
    <plugin name="cordova-plugin-badge" spec="~0.8.8" />
    <plugin name="cordova-plugin-globalization" spec="~1.11.0" />
    <plugin name="cordova-plugin-device" spec="~2.0.3" />
    <plugin name="cordova-plugin-geolocation" spec="~4.0.2" />
    <plugin name="cordova-plugin-file-transfer" spec="~1.7.1" />
    <plugin name="cordova-plugin-file" spec="^6.0.2" />
    <plugin name="cordova-plugin-whitelist" spec="~1.3.4" />
    <plugin name="cordova-plugin-statusbar" spec="~2.4.3" />
    <plugin name="cordova-plugin-splashscreen" spec="~5.0.3" />
    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.2.0" />
    <plugin name="cordova-plugin-telerik-imagepicker" spec="~2.3.3" />
    <plugin name="cordova-plugin-video-editor" spec="~1.1.3" />
    <plugin name="cordova-plugin-media-capture" spec="~3.0.3" />
    <plugin name="cordova-plugin-network-information" spec="~2.0.2" />
    <plugin name="cordova-plugin-inappbrowser" spec="~3.1.0" />
    <plugin name="cordova-plugin-screen-orientation" spec="~3.0.2" />
</widget>

EOF

package.json <<EOF
{
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.1.0",
    "@agm/js-marker-clusterer": "^1.1.0",
    "@angular/common": "9.1.7",
    "@angular/core": "9.1.7",
    "@angular/forms": "9.1.7",
    "@angular/platform-browser": "9.1.7",
    "@angular/platform-browser-dynamic": "9.1.7",
    "@angular/router": "9.1.7",
    "@ionic-native/badge": "^5.26.0",
    "@ionic-native/camera": "^5.26.0",
    "@ionic-native/core": "^5.26.0",
    "@ionic-native/device": "^5.26.0",
    "@ionic-native/diagnostic": "^5.26.0",
    "@ionic-native/facebook": "^5.26.0",
    "@ionic-native/file": "^5.26.0",
    "@ionic-native/file-transfer": "^5.26.0",
    "@ionic-native/geolocation": "^5.26.0",
    "@ionic-native/globalization": "^5.26.0",
    "@ionic-native/google-maps": "^5.5.0",
    "@ionic-native/image-picker": "^5.26.0",
    "@ionic-native/in-app-browser": "^5.26.0",
    "@ionic-native/ionic-webview": "^5.26.0",
    "@ionic-native/keyboard": "^5.26.0",
    "@ionic-native/media-capture": "^5.26.0",
    "@ionic-native/native-storage": "^5.26.0",
    "@ionic-native/network": "^5.26.0",
    "@ionic-native/onesignal": "^5.26.0",
    "@ionic-native/open-native-settings": "^5.26.0",
    "@ionic-native/screen-orientation": "^5.26.0",
    "@ionic-native/social-sharing": "^5.26.0",
    "@ionic-native/splash-screen": "^5.26.0",
    "@ionic-native/status-bar": "^5.26.0",
    "@ionic-native/video-editor": "^5.26.0",
    "@ionic/angular": "^5.1.1",
    "@ionic/storage": "^2.2.0",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "angularx-social-login": "^2.2.1",
    "chart.js": "^2.9.3",
    "cordova-android": "^8.1.0",
    "cordova-ios": "^5.1.1",
    "cordova-open-native-settings": "^1.5.2",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-camera": "git+https://github.com/apache/cordova-plugin-camera.git",
    "cordova-plugin-device": "^2.0.3",
    "cordova-plugin-facebook4": "^6.2.0",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-geolocation": "^4.0.2",
    "cordova-plugin-globalization": "^1.11.0",
    "cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git",
    "cordova-plugin-googlemaps-sdk": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git",
    "cordova-plugin-inappbrowser": "^3.1.0",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.1.2",
    "cordova-plugin-media-capture": "^3.0.3",
    "cordova-plugin-nativestorage": "^2.3.2",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-screen-orientation": "^3.0.2",
    "cordova-plugin-splashscreen": "~5.0.3",
    "cordova-plugin-statusbar": "~2.4.3",
    "cordova-plugin-telerik-imagepicker": "^2.3.3",
    "cordova-plugin-video-editor": "^1.1.3",
    "cordova-plugin-whitelist": "~1.3.4",
    "cordova-plugin-x-socialsharing": "^5.6.5",
    "cordova-res": "^0.9.0",
    "cordova.plugins.diagnostic": "^5.0.1",
    "core-js": "^2.5.4",
    "es6-promise-plugin": "^4.2.2",
    "event.es6": "^1.2.2",
    "hammerjs": "^2.0.8",
    "ionicons": "^5.0.1",
    "js-marker-clusterer": "^1.0.0",
    "moment": "^2.24.0",
    "ng-socket-io": "^0.2.4",
    "ng2-charts": "^2.3.0",
    "npm": "^6.13.7",
    "onesignal-cordova-plugin": "^2.8.3",
    "rxjs": "^6.5.3",
    "rxjs-compat": "^6.5.3",
    "tslib": "^1.9.0",
    "uniqid": "^5.2.0",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/architect": "0.901.6",
    "@angular-devkit/build-angular": "0.901.6",
    "@angular-devkit/core": "9.1.6",
    "@angular-devkit/schematics": "9.1.6",
    "@angular/cli": "9.1.6",
    "@angular/compiler": "9.1.7",
    "@angular/compiler-cli": "9.1.7",
    "@angular/language-service": "9.1.7",
    "@ionic/angular-toolkit": "~2.2.0",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.6.9",
    "codelyzer": "~4.5.0",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-splashscreen": "^5.0.3",
    "cordova-plugin-statusbar": "^2.4.3",
    "cordova-plugin-whitelist": "^1.3.4",
    "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",
    "node-sass": "^4.13.1",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~5.17.0",
    "typescript": "~3.7.4"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-nativestorage": {},
      "cordova-open-native-settings": {},
      "cordova-plugin-badge": {},
      "cordova-plugin-globalization": {},
      "cordova-plugin-device": {},
      "cordova-plugin-geolocation": {},
      "cordova-plugin-file-transfer": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-telerik-imagepicker": {
        "PHOTO_LIBRARY_USAGE_DESCRIPTION": " "
      },
      "cordova-plugin-video-editor": {},
      "cordova-plugin-media-capture": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-file": {},
      "cordova-plugin-screen-orientation": {},
      "onesignal-cordova-plugin": {},
      "cordova.plugins.diagnostic": {
        "ANDROID_SUPPORT_VERSION": "28.+"
      },
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "com.googlemaps.ios": {},
      "cordova-plugin-x-socialsharing": {
      },
      "cordova-plugin-googlemaps": {
      },
      "cordova-plugin-camera": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      }
    },
    "platforms": [
      "ios",
      "android"
    ]
  }
}
EOF

Thanks

timbru31 commented 4 years ago

Thanks a lot for your issue, however the issue template exists for a reason. 😊
It helps us to debug the issue further and to provide a solution much faster. With important information missing, we unfortunately can't help you.

Therefore, please edit this issue accordingly or close and create a new one and make sure to provide all the required information.

erisu commented 4 years ago

I also want to make a note that there is no official version 4.2.0 release.

https://www.npmjs.com/package/cordova-plugin-camera

simetin commented 4 years ago

I've made a repo to show the issue: https://github.com/simetin/cordova-camera-plugin-issue-demo Here are the steps I did to create the demo:

  1. I've simply started a new ionic project
  2. Installed Android 8.1.0
  3. Installed Cordova-plugin-camera 4.2.0 from Github
  4. Installed @ionic-native/camera
  5. Added the code provided by Ionic:

    openCamera() {
    const options: CameraOptions = {
      quality: 100,
      destinationType: this.camera.DestinationType.FILE_URI,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
    }
    
    this.camera.getPicture(options).then((imageData) => {
      console.log(imageData);
    }, (err) => {
      console.log(err);
    });
    }

Is there anything else that you want me to provide you ?

Thanks

timbru31 commented 4 years ago

a) you are using an unsupported version b) this is a duplicate of https://github.com/apache/cordova-plugin-camera/issues/597 c) we are aware that the master is broken due to PR #588

simetin commented 4 years ago

Okay, thank you and sorry