nostrebor
nostrebor

Reputation: 351

Viewing Console Log in Crosswalk WebView

Does anyone know if there is a way to view the data written by Javascript console.log from an embedded Crosswalk webview?

Googling this has not been very helpful, and I can't find documentation regarding the question.

Upvotes: 2

Views: 2406

Answers (3)

P. Stresow
P. Stresow

Reputation: 308

I'm using Crosswalk embedded 14 stable, this is what I did:

Using Android Studio I first followed this guide: https://diego.org/2015/01/07/embedding-crosswalk-in-android-studio/

After that this is what you have to do to handle console log by yourself:

xWalkWebView.setUIClient( new XWalkUIClient(xWalkWebView){
            @Override
            public boolean onConsoleMessage(XWalkView view, String message, int lineNumber, String sourceId, ConsoleMessageType messageType) {
                Log.i(TAG, message);
                return super.onConsoleMessage(view, message, lineNumber, sourceId, messageType);
            }
        });

Upvotes: 6

Mostafa Abdelraouf
Mostafa Abdelraouf

Reputation: 628

To enable Remote Debugging from Chrome I also needed to add --enable-remote-debugging to command line params of make_apk.py to become something like this

python make_apk.py --enable-remote-debugging --package=com.example.app  --manifest=path_to_manifest

I am using Crosswalk 7 on Windows

Upvotes: 0

Shouqun
Shouqun

Reputation: 856

There are two ways to view the JavaScript console log in Crosswalk WebView:

  1. From adb logcat, since Crosswalk is based on Chromium, all JavaScript console logs are redirected to adb log. you can view it via

    adb logcat -s chromium

  2. From Chrome remote debugging tool, Crosswalk supports Chrome's remote debug protocol. So you can connect the device to a PC/Mac host running desktop Chrome, and open chrome://inspect in the desktop Chrome, you'll find Crosswalk WebView's page is listed, and then inspect the page like inspecting desktop tab.

    You can refer: https://crosswalk-project.org/#wiki/Remote-Debugging-on-Android https://developer.chrome.com/devtools/docs/remote-debugging#open-webview

Upvotes: 5

Related Questions