Cordova "Console" 插件不工作

Cordova "Console" plugin not working

我通过

添加了插件
cordova plugin add cordova-plugin-console

我在adroid上模拟创建的默认项目(带设备就绪事件演示)

在logcat我看到了

I/chromium( 1330): [INFO:CONSOLE(173)] "Received Event deviceReady", source: file:///android_asset/www/plugins/cordova-plugin-console/www/console-via-logger.js (173)
D/PluginManager( 1330): exec() call to unknown plugin: Console

这是一个问题,因为在调用 console.log 时我没有跟踪行,这在调试时会造成一些麻烦。

这是我的'compacted'js代码

var app = {
    // Application Constructor
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    //
    // The scope of 'this' is the event. In order to call the 'receivedEvent'
    // function, we must explicitly call 'app.receivedEvent(...);'
    onDeviceReady: function() {
        var parentElement = document.getElementById("deviceready");
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event deviceReady');
    },

};

app.initialize();

另外,我想知道为什么一个新创建的项目已经报错了!!

编辑:我已经尝试删除并重新添加插件,但这并没有解决问题。

通过 cordova plugin 删除和读取插件无效。

简单地说,使用 npm 安装插件

cordova plugin remove cordova-plugin-console
npm install cordova-plugin-console

重新启动 android 模拟我的 cordova 项目后,一切正常。

现在我有了预期的日志行(这里分成两行只是为了更好的阅读):

I/chromium( 1416): [INFO:CONSOLE(36)] "Received Event deviceReady", 
source: file:///android_asset/www/js/index.js (36)