简体   繁体   English

Cordova console.log 不工作

[英]Cordova console.log not working

Hello I downloaded and installed node.js as I have done million times also I installed cordova as mentioned in their docs .您好,我下载并安装了 node.js,因为我已经安装了 100 万次,我还按照他们的文档中的说明安装了 cordova。 Furthermore I installed console.plugin with "cordova plugin add org.apache.cordova.console".此外,我使用“cordova plugin add org.apache.cordova.console”安装了 console.plugin。 Finally I did cordova build android and the cordova emulate android, and inside www/js/index.js onDeviceReady I simply entered this console.log('test');最后我做了 cordova 构建 android 和 cordova 模拟 android,在 www/js/index.js onDeviceReady 里面我只是输入了这个console.log('test');

I'm new with cordova and I cant figure out why I dont see and output in my terminal.我是 cordova 的新手,我不明白为什么我在终端机上看不到 output。

PS: I'm on ubuntu 12.04 LTS 64bit, and I dont use eclipse. Shouldn't I see the console.log output in my terminal window? PS:我在 ubuntu 12.04 LTS 64 位上,我不使用 eclipse。我不应该在我的终端 window 中看到 console.log output 吗?

Using alert() is a rather dilettantish debug methodology.使用alert()是一种相当浅薄的调试方法。 The most simple is to use a hardware device or an emulator with adb and chrome://inspect .最简单的方法是使用硬件设备或带有adbchrome://inspect的模拟器。 This provides the debug bridge for the Cordova WebView , as well as the JS console, JS debugger, DOM inspector, etc. within Chrome.这为 Cordova WebView提供了调试桥,以及 Chrome 中的 JS 控制台、JS 调试器、DOM 检查器等。

See Get Started with Remote Debugging Android Devices .请参阅远程调试 Android 设备入门

The output will appear in an output window, not in the terminal window. 输出将出现在输出窗口中,而不是终端窗口中。

I run my Android Cordova apps in Eclipse and logs appear in the Logcat output window, similarly with iOS apps and Xcode, they appear in the Xcode output window. 我在Eclipse中运行Android Cordova应用程序,日志出现在Logcat输出窗口中,类似于iOS应用程序和Xcode,它们出现在Xcode输出窗口中。

You could always just alert() or navigator.notification.alert() to quickly see your logged values. 您可以始终只使用alert()navigator.notification.alert()来快速查看记录的值。

Hope this helps. 希望这可以帮助。

From the CLI run your Android project and display console output from chromium (if using Crosswalk) or SystemWebViewClient. 从CLI运行Android项目并显示chrome(如果使用Crosswalk)或SystemWebViewClient的控制台输出。 View Debugging priority and above logs from these places, and silence everything else. 从这些位置查看调试优先级和以上日志,并使其他所有内容静音。

cordova run android && adb logcat chromium:D SystemWebViewClient:D *:S

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM