Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cordova_plugins.js is not updated after adding new plugin

I just started using cordova with android.

I have a problem when adding plugins.

I used cordova plugin to add org.apache.cordova.camera from cmd in Win7. It is added but not in cordova_plugins.js file.

File is getting updated when I type cordova run android this in cmd but then all my code is deleted and replaced with skeletal web-based application. Why is this happening? How to automatically get this file updated?

This is how my cordova_plugins.js looks like:

cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
    {
        "file": "plugins/org.apache.cordova.dialogs/www/notification.js",
        "id": "org.apache.cordova.dialogs.notification",
        "merges": [
            "navigator.notification"
        ]
    },
    {
        "file": "plugins/org.apache.cordova.dialogs/www/android/notification.js",
        "id": "org.apache.cordova.dialogs.notification_android",
        "merges": [
            "navigator.notification"
        ]
    },
    {
        "file": "plugins/org.apache.cordova.vibration/www/vibration.js",
        "id": "org.apache.cordova.vibration.notification",
        "merges": [
            "navigator.notification"
        ]
    }
];
module.exports.metadata = 
// TOP OF METADATA
{
    "org.apache.cordova.dialogs": "0.2.5",
    "org.apache.cordova.vibration": "0.3.6"
}
// BOTTOM OF METADATA
});

As you can see there is no camera plugin. It is added in my project, but not in this file and that's reason it is not working when I try to use it in my js files.

I hope you understood what I am saying.

like image 879
consigliere Avatar asked Jan 05 '14 04:01

consigliere


2 Answers

Does it show up in the list when you type:

cordova plugin ls

Did you rerun:

cordova build wp7
like image 76
Jon McEroy Avatar answered Nov 05 '22 06:11

Jon McEroy


What worked for me:

  • Delete ./platforms [or move to some other place as a backup]
  • Delete ./plugins [or move to some other place as a backup]
  • Build e.g: ionic cordova build android --prod or ionic cordova prepare
  • This resets everything, fetches FRESH plugins from config.xml

PS: add/remove/update versions of plugins and packages from package.json and run npm i beforehand.

You might need to update config.xml with the right versions too (if you are trying to fix a version conflict)

like image 1
Deepak Thomas Avatar answered Nov 05 '22 06:11

Deepak Thomas