Android: Logcat not working for JS console.log ()

My application is a combination of Android native, html5. Until the last week I can see the log messages from my own code and javascript code running inside the WebView. But unexpectedly, Logcat does not show console messages from javascript, although it shows log messages from my own code. Any ideas?

Thanks in advance. Venkat

+6
source share
5 answers

You can try adding a console message handler to your WebView by creating your own WebChromeClient:

class MyWebChromeClient extends WebChromeClient { @Override public boolean onConsoleMessage(ConsoleMessage cm) { Log.d("CONTENT", String.format("%s @ %d: %s", cm.message(), cm.lineNumber(), cm.sourceId())); return true; } } 

And then attach it:

 someWebView.setWebChromeClient(new MyWebChromeClient()); 
+16
source

For only the native version of android and html5 (not phonegap / cordova), this covers how to display console messages in logcat. http://developer.android.com/guide/webapps/debugging.html#WebView

An alternative is to use jsconsole.com. Remote debugging extends to http://jsconsole.com/remote-debugging.html

+14
source

I am running PhoneGap 2.9.1.

After doing some sort of searching, I expected Console.log to appear in the Eclipse LogCat under the WebView tag, so I wasn't sure if it worked.

After some game, I found that console.log () is displayed in LogCat under the tag CordovaLog .

+1
source

This command works too well

adb shell "logcat | grep" Web console "

I found the answer here

+1
source

If you want to test your cordova application in your browser, just like you are testing any other web application.

You can use: cordova serve . This will launch the hybrid application locally. You can open the url http: // localhost: 8000 and check the item for console logs. You can change the elements of the DOM, CSS.

0
source

Source: https://habr.com/ru/post/919924/


All Articles