I have been using three different HTC phones, almost exclusively, and have never had this issue. Here are a few things to check:
- Make sure USB debugging is enabled.
- Make sure your Webview has a WebChromeClient set. The browser used in Webview does not implement console.log().
- It should be easy to see the output of adb logcat, but to make it easier, filter the output.
Turn on USB debugging:
- Disconnect your device from your computer.
- Go to Settings -> Applications -> Development -> Select "Enable USB Debugging"
- Plugin to computer. (Make sure you have the correct drivers installed to use ADB - more info here: http://developer.android.com/guide/developing/device.html)
Set a WebChromeClient that overrides onConsoleMessage():
//Set the output prefix so you can filter adb logcat results later
public static final String TAG = "Your-Application-Name";
myWebView = (WebView) findViewById(R.id.webview);
//Not going to have much luck running JS without this:
myWebView.getSettings().setJavaScriptEnabled(true);
//Override onConsoleMessage() to output to the Log.
myWebView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onConsoleMessage(ConsoleMessage cm) {
Log.d(TAG, cm.message() + " -- From line "
+ cm.lineNumber() + " of "
+ cm.sourceId() );
return true;
}
});
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:
adb logcat tag-name:log-level *:S
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:
adb logcat Your-Application-Name:D *:S
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. :)