consigliere
consigliere

Reputation: 1007

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.

Upvotes: 7

Views: 10222

Answers (3)

Deepak Thomas
Deepak Thomas

Reputation: 3535

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)

Upvotes: 1

mgreca
mgreca

Reputation: 86

I was having the same issue with another plugin, and I did the old and magic trick: I restarted Windows (Windows 7)

After restart Windows I did the following steps:

  • Removed all plugins (I don't know if it is necessary to remove all)
  • Removed cordova_plugins.js
  • I executed platforms/android/cordova/clean.bat
  • Mi plugin had a dependency (Inappbrowser), so I installed Inappbrowser first.
  • I installed the plugin

I don't know if all these steps are necessary, maybe just works restarting Windows. However, it worked for me.

Upvotes: 0

Jon McEroy
Jon McEroy

Reputation: 515

Does it show up in the list when you type:

cordova plugin ls

Did you rerun:

cordova build wp7

Upvotes: 1

Related Questions