0

I'm studying new Cordova 5.0. I'm using Sublime Text. So I'd like to use adb from command line to logcat to debug javascript errors.

do you know wich combinations of parameters to use?

I tried

adb logcat *:S CordovaLog:D 

as seen in a blog, but in case of JS no line appears

Also, I tried this, taht could be what I'm looking for

adb logcat SystemWebChromClient:D 

but in this case it logs everythings, not only the rows of DEBUG type from SystemWebChromClient.

What am I doing wrong?

2 Answers 2

4

After try and retry and retry ...

The solution was to mix my previous two attempts and fix a typo (missing letter 'e' in the word "Chrom" of "SystemWebChromeClient"). So this works

adb logcat *:S SystemWebChromeClient:D 
Sign up to request clarification or add additional context in comments.

Comments

0

You should implement this to achieve this:

WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebChromeClient(new WebChromeClient() {
  public void onConsoleMessage(String message, int lineNumber, String sourceID) {
    Log.d("MyApplication", message + " -- From line "
                         + lineNumber + " of "
                         + sourceID);
  }
});

More information: http://developer.android.com/guide/webapps/debugging.html

If you've not a specific reason to use ADB to debug your webview, i would go for inspecting webview on chrome developer tools on your computer. More information: https://developer.chrome.com/devtools/docs/remote-debugging#debugging-webviews

1 Comment

Why use a complex solution to a simple problem? I only ask a way to filter out logcat from SystemWebChrome. In this way I track every js console.log and every javascript error. No need for more complex tools

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.