Adding plugin fails because it already exists, removing plugin fails because it doesn't exist


#1

I’ve some how managed to mess up my Ionic project… some help would be greatly appreciated.

I’m trying to add cordova-plugin-camera so I what I’m doing is:

$ cordova plugin add cordova-plugin-camera this returns an error:

Installing "cordova-plugin-camera" for android
Android Studio project detected
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-camera': CordovaError: Uh oh!
"C:\xampp\htdocs\project x\anonymous-social\platforms\android\app\src\main\res\xml\camera_provider_paths.xml" already exists!
    at copyNewFile (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\lib\pluginHandlers.js:261:45)
    at install (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\lib\pluginHandlers.js:51:17)
    at ActionStack.process (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\ActionStack.js:56:25)
    at PluginManager.doOperation (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:114:20)
    at PluginManager.addPlugin (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:144:17)
    at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\Api.js:247:74
    at _fulfilled (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:854:54)
    at self.promiseDispatch.done (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:883:30)
    at Promise.promise.promiseDispatch (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:816:13)
    at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:570:49
(node:26116) UnhandledPromiseRejectionWarning: CordovaError: Uh oh!
"C:\xampp\htdocs\project x\anonymous-social\platforms\android\app\src\main\res\xml\camera_provider_paths.xml" already exists!
    at copyNewFile (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\lib\pluginHandlers.js:261:45)
    at install (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\lib\pluginHandlers.js:51:17)
    at ActionStack.process (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\ActionStack.js:56:25)
    at PluginManager.doOperation (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:114:20)
    at PluginManager.addPlugin (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:144:17)
    at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\Api.js:247:74
    at _fulfilled (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:854:54)
    at self.promiseDispatch.done (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:883:30)
    at Promise.promise.promiseDispatch (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:816:13)
    at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:570:49
(node:26116) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:26116) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Since it seems to exist I may as well try removing it:

$ cordova plugin rm cordova-plugin-camera which then tells me:

> cordova plugin remove cordova-plugin-camera --save
Uninstalling cordova-plugin-camera from android

Android Studio project detected

(node:18656) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\xampp\htdocs\project x\anonymous-social\platforms\android\app\src\main\assets\www\cordova_plugins.js'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.writeFileSync (fs.js:1299:33)
    at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\cordova-common\src\PluginManager.js:134:16
    at _fulfilled (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:854:54)
    at self.promiseDispatch.done (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:883:30)
    at Promise.promise.promiseDispatch (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:816:13)
    at C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:877:14
    at runSingle (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:137:13)
    at flush (C:\xampp\htdocs\project x\anonymous-social\platforms\android\cordova\node_modules\q\q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
(node:18656) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18656) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

At this point I figure there is a problem with my Android platform so I remove the platform:

$ cordova platform remove android --save
Removing platform android from config.xml file...
Removing android from cordova.platforms array in package.json

and then adding it back seems to work fine as it returns:

--save flag or autosave detected
Saving android@~7.0.0 into config.xml file ...

Does anyone have an idea what is going? My android platform seems to be a little messed up because other plugins are doing the same thing… any help? Thank you!