I am developing the application in HTML which is calling the console.log()
from Javascript to provide me logs during the development about what happens in the web page code.
Unfortunately when I use the adb logcat
command to check logs I can see output from all other applications, but not the output from my JavaScript code. I can see even the log from web browser that the page is loaded, but not console.log()
output from my JavaScript code executed in the web browser.
According to information on this page (http://developer.android.com/guide/webapps/debugging.html) it should work.
I am testing on HTC WildFire and HTC Desire HD.
Edited after more then 6 months
After some time and experience with different devices (phones, TVs, set top boxes, WebViews, UIWebViews...) my advice is to do the remote logging from JavaScript and not relying on the console.log() or other methods - see the nice trick with the image loading here.
Do not miss the presentation here Hope this helps! STeN
Try the following:
1) Open the devices tab and make sure that the device you have connected is selected/highlighted.
2) Make sure USB Debugging is enabled on your device. Here is what you need to do for this:
Logcat generates a lot of stuff on devices in addition to yours so you may have to filter this.
You can try to "grep" your log output if you've tagged it. For example: acording to your article the output should look like:
If you use the command (assuming you are using a Linux, Mac OS or anything else with a grep command)
it will reduce the output to the keyword specified within these quotation marks. If you add a unique tag to your output you can also filter this so you get only things you want to see.
will stop this logcat process.
In the default browser on Android 2.3.3 (and presumably from then on) you can simply use the built in javascript console:
about:debug
in the address bar and hit enterAt the top, you'll see a bar labeled "JavaScript Console".
I had the same problem, I solve it by doing the following:
1/ when you initialize your webview, add a javascript bridge class:
2/ create the class JSBridge with a log function
3/ in your javascript you can now call
Might be a bit overkill for your problem, but you can also do a LOT more with that solution
I have been using three different HTC phones, almost exclusively, and have never had this issue. Here are a few things to check:
Turn on USB debugging:
Set a WebChromeClient that overrides onConsoleMessage():
More info on onConsoleMessage() here: http://developer.android.com/reference/android/webkit/WebChromeClient.html#onConsoleMessage(java.lang.String, int, java.lang.String)
More info on debugging in general here: http://developer.android.com/guide/webapps/debugging.html
Filter the output of adb logcat:
tag-name matches the string specified in Log.x log-level matches the log level you indicated when calling Log.x <---
Example relating to code above:
This will show all d level logs for the matching tag, Your-Application-Name, and silence everything else.
More info on adb filtering here: http://developer.android.com/guide/developing/tools/adb.html#logcat
Hope it helps! I know it was a bit of summarizing of the other answers, but, the fact is, it takes all of the steps to make it work. :)
See this: How to display console.log() output in PhoneGap app using Eclipse and HTC Desire HD?
You can get around it by using remote debugging in jsconsole.com.