Error in Phonegap Application: Uncaught module cor

2019-03-17 12: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

3条回答
Root(大扎)
2楼-- · 2019-03-17 12:55

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.

乱世女痞
3楼-- · 2019-03-17 13:01

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
查看更多
相关推荐>>
4楼-- · 2019-03-17 13:15

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.

查看更多
登录 后发表回答