Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in Phonegap Application: Uncaught module cordova/plugin_list already defined

Tags:

I have been trying to resolve many issues from having updated from Phonegap 2 to Phonegap 3.3 but I can't seem to fix this one.

I have read from some users that uncaught module exceptions can cause imported plugins to stop functioning. I am having some odd bugs with a local notification plugin so I would like to fix this issue and see if it helps.

Here is the error as it appears in logcat within Eclipse:

[INFO:CONSOLE(79)] "Uncaught module cordova/plugin_list already defined", source: file:///android_asset/www/cordova.js (79)

I know that this is some odd issue arising from the nature of Phonegap 3 (Plugins have been reworked). And I think that the problem lies in importing a cordova_plugins.js script as the top line of that script reads:

cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
    "file": "plugins/org.apache.cordova.file/www/DirectoryEntry.js",
    "id": "org.apache.cordova.file.DirectoryEntry",
    "clobbers": [
        "window.DirectoryEntry"
    ]
}, ...

And this is the only place that I can find the existence of cordova/plugin_list as referenced in the error.

However, I am not sure of the correct way of fixing this issue. I did not use plugman to import my plugins, but instead the CLI commands outlined in the Phonegap 3.3 API

like image 296
Gthoma2 Avatar asked Jan 02 '14 19:01

Gthoma2


2 Answers

One cause of this problem is importing the cordova_plugins.js in your html file.

Check if it is the case for you and remove it.

like image 82
grytrn Avatar answered Oct 14 '22 07:10

grytrn


The file cordova.js automatically loads cordova_plugins.js.

So another obvious way to end up with this error is if you inadvertently put the following code twice on your page.

<script type="text/javascript" src="cordova.js"></script> 

I lost hours on this same error only to realise I had added cordova.js at both the top and the bottom of the page.

like image 44
elMarquis Avatar answered Oct 14 '22 07:10

elMarquis