Unable to use the camera plugin cordova-plugin-camera install issue

Error received in the chrome Debug console from device:

Native: tried calling Camera.getPicture, but the Camera plugin is not installed.
Install the Camera plugin: ‘ionic cordova plugin add cordova-plugin-camera’

guys i deleted the Node_modules and did a full NPM Install and same issue

below is my package.json

{
    "name": "CommunitiesIONICV2",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "4.1.3",
        "@angular/compiler": "4.1.3",
        "@angular/compiler-cli": "4.1.3",
        "@angular/core": "4.1.3",
        "@angular/forms": "4.1.3",
        "@angular/http": "4.1.3",
        "@angular/platform-browser": "4.1.3",
        "@angular/platform-browser-dynamic": "4.1.3",
        "@ionic-native/camera": "^3.13.1",
        "@ionic-native/core": "3.12.1",
        "@ionic-native/facebook": "^3.12.1",
        "@ionic-native/geolocation": "^3.12.1",
        "@ionic-native/in-app-browser": "^3.12.1",
        "@ionic-native/splash-screen": "3.12.1",
        "@ionic-native/status-bar": "3.12.1",
        "@ionic/cloud-angular": "^0.12.0",
        "@ionic/storage": "2.0.1",
        "cordova-android": "^6.2.3",
        "cordova-plugin-camera": "^2.4.1",
        "cordova-plugin-compat": "^1.1.0",
        "cordova-plugin-console": "^1.0.5",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-facebook4": "^1.9.1",
        "cordova-plugin-geolocation": "^2.4.3",
        "cordova-plugin-inappbrowser": "^1.7.1",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.2",
        "cordova-plugin-whitelist": "^1.3.1",
        "ionic-angular": "3.5.0",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "rxjs": "5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.12"
    },
    "devDependencies": {
        "@ionic/app-scripts": "1.3.12",
        "@ionic/cli-plugin-cordova": "1.4.0",
        "@ionic/cli-plugin-ionic-angular": "1.3.1",
        "typescript": "2.3.4"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-geolocation": {},
            "cordova-plugin-inappbrowser": {},
            "cordova-plugin-facebook4": {
                "APP_ID": "1863707417227215",
                "APP_NAME": "CommunitiesV2"
            },
            "cordova-plugin-compat": {}
        },
        "platforms": [
            "android"
        ]
    }
}

Dont know what am i doing wrong. Please can you help?

Try removing the platform, then add it back in. I have found that this solves about 80% of my plugin issues.

When exactly to you get the error? When and how are you calling getPicture?

This is a big issue and i am unable stuck :frowning:

I deleted the android platform and reinstalled it – didn’t work

when do i get the error?

its a button call and behind the call i call this lifted from the ionicframework site:

import { Camera, CameraOptions } from '@ionic-native/camera'

...

launchCamera() {
    const options: CameraOptions = {
      quality: 100,
      destinationType: this.camera.DestinationType.DATA_URL,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
    }

    this.camera.getPicture(options).then((imageData) => {
      // imageData is either a base64 encoded string or a file URI
      // If it's base64:
      let base64Image = 'data:image/jpeg;base64,' + imageData;
    }, (err) => {
      // Handle error
    });
  }

Now i cant event reinstall the Cordova Camera plugin. i am following what we have in the following post

i keep getting this error

“Error: Cannot find plugin.xml for plugin “cordova-plugin-camera”. Please try adding it again.”

I dont know what is this plugin.xml and what to do with it when i find it

So stuck… will appreciate all help i can get :slight_smile:

The last time I had to downgrade my systems cordova to 6.0.5. then reinstall the camera plugin.

npm install cordova@6.0.5

I hope it works in your case

Hi zeta

tried it and it didnt work, same error again

“Error: Cannot find plugin.xml for plugin “cordova-plugin-camera”. Please try adding it again.”

Will appreciate any help i can get

i created a new project and apparently it worked on it. but it does not work on my package

Will appreciate it if i can get some ideas i can try. my package.json is above

When you say ‘remove the platform’, do you mean something like npm uninstall cordova?

Hi Shashank,

Can you please try the following comment

ionic cordova platform remove android ( If you are using android)

then add platform using the following comment

ionic cordova platform remove android

I also found that this solves your plugin issues.

after removing both android and ios platform try deleting the platform and plugin folder from your project.
and after that re-add both the platforms…

Just do this:

ionic cordova platform rm android
ionic cordova prepare android

And then, try again.