Unable to add Camera plugin


#1

I am trying to add camera plugin but I am getting this error.

D:\ionic project>ionic cordova plugin add cordova-plugin-camera> cordova plugin add cordova-plugin-camera --save
:heavy_multiplication_x: Running command - failed!`

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova plugin add cordova-plugin-camera --save (exit code 1):
Installing “cordova-plugin-camera” for android
Failed to install ‘cordova-plugin-camera’: CordovaError: Version of installed plugin: “cordova-plugin-compat@1.0.0” does not satisfy dependency plugin requirement “cordova-plugin-compat@^1.1.0”. Try --force to use installed plugin as dependency.
at C:\Users\shashank\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:581:33
at _fulfilled (C:\Users\shashank\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Users\shashank\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Users\shashank\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:749:13)
at C:\Users\shashank\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:509:49
at flush (C:\Users\shashank\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:108:17)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
Error: Version of installed plugin: “cordova-plugin-compat@1.0.0” does not satisfy dependency plugin requirement “cordova-plugin-compat@^1.1.0”. Try --force to use installed plugin asPreformatted text dependency.

Please help me. Thanks


#2

Try the first line but leave out Cordova. Ionic plugin add…etc…, Second command should/could be ionic plugin --save Cordova-plugin-camera. You may have to add the plugin to your json.manifest and/or config.xml. Can’t recall right now. This is how I worked around the same issue.

Basically, if you look at ionic’s component docs for adding the camera plugin but leave Cordova out of the 1st command, it should work.


#3

The error message looks pretty self-explanatory to me. You have a version of cordova-plugin-compat installed that is too old to be compatible with the camera plugin you are trying to install, so you must update it to at least 1.1.0.


#4

The new CLI requires the “ionic cordova plugin” syntax and no longer allows “ionic plugin”


#5

Didn’t see that coming.


#6

Yeah, I have version 2.4.1 in an ionic 2 project. Might be time to upgrade. Though, the ionic-Cordova-plugin syntax returned error messages in ionic 2 as well. Not sure if there’s a difference between how 2 and 3 interpret or process that line. I will say, the ionic team has responded to a lot of questions with a reminder that 3 is in beta, and to except quirks and changes.


#7

Sorry, but I have no idea what you are trying to say here. I am saying that the error message you posted suggests that you need to upgrade cordova-plugin-compat. This has absolutely nothing whatsoever to do with the Ionic CLI version. Furthermore, the v3 CLI is no longer in beta. It has been released.


#8

I’m a responder to the poster as well


#9

First delete the folder @ /plugins/cordova-plugin-compat/
Then try to install again with:

ionic cordova plugin add cordova-plugin-compat

#10

I noticed that the cordova-plugin-camera comes with a version of cordova-plugin-compat which has been causing a version confusion. So I did this:

ionic cordova plugin remove --force cordova-plugin-compat
ionic cordova plugin add cordova-plugin-camera

No need to reinstall the cordova-plugin-compat after a successful install.


#11

Thanks, that fixed the issue for me!

Why don’t we need to re-install cordova-plugin-compat ?


#12

plugin camera reinstall cordova-plugin-compat v1.1 automatic


#13

If you want to add cordova plugin into ionic v1 project you can do this steps
1>Remove android
cordova platform remove android
2>Add Android
Cordova platform add android@5.0.0

3>Remove Cordova Compat plugin
cordova plugin remove --force cordova-plugin-compat
4>Add Cordova compat plugin
cordova plugin add cordova-plugin-compat
5>Add Cordova camera plugin
cordova plugin add cordova-plugin-camera
or
cordova plugin add https://github.com/apache/cordova-plugin-camera.git


#14

Nothing helped me - I did this

cordova plugin add https://github.com/apache/cordova-plugin-camera.git
as described here https://github.com/apache/cordova-plugin-camera