24

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

Gthoma2
  • 687
  • 1
  • 9
  • 22
  • Hi, I reccomend to you not to upgrade, Create a new proyect with cordova from cli, install your plugins with cli too and copy your www old proyect to new one. I think that it'll prevent many kind of mistakes to you. Regards. – JSG33kC0d3 Jan 09 '14 at 07:52

3 Answers3

25

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.

ngrashia
  • 9,869
  • 5
  • 43
  • 58
grytrn
  • 423
  • 3
  • 7
  • THank you grytrn, this solved the issue for me... I could have sworn that I needed that call to cordova_plugins.js, but it seems like my applicaiton is loading fine without it, and I am no longer receiving the error. – Gthoma2 Jan 31 '14 at 21:04
  • 3
    I don't have the cordova_plugins.js in my HTML file. But I still see the same problem with my project. Any clue on this @grytrn? – Lohith Korupolu Mar 25 '14 at 06:40
  • @LohithKrishna I was seeing this exception while trying to use cordova plugins in a remote site. See my answer in this thread. I'm not sure if you have the same situation or not. http://stackoverflow.com/a/26551455/534495 – sorin.silaghi Oct 24 '14 at 16:50
  • @LohithKrishna without details I can't help. – grytrn Mar 08 '15 at 23:16
  • A whole pile of my troubles were rooted in this. Great answer, thanks. – GRY Jun 30 '15 at 05:21
18

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.

elMarquis
  • 7,450
  • 4
  • 38
  • 42
-4

You must have to create and deploy any phonegap project/application using Phonegap Command Line Interface

To Create any project write following command on command line:

$ phonegap create <path> <package_name> <project_name>

i.e.

$ phonegap create hello com.example.hello HelloWorld

To add any platform to your project:

cd <path_to_project>
$ phonegap build <platform>

i.e.

cd hello
$ phonegap build ios
$ phonegap build android

To add any plugin feature to your project:

cd <path_to_project>
$ phonegap local plugin add <path_to_plugin>

i.e.

cd hello
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
Bhavik Modi
  • 1,517
  • 14
  • 29