Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug webview remotely?

How can I do debug/inspect element of apk webview.
I have tried this but it is helpful only for chrome not for apk.

Please suggest me

like image 911
Kundan Atre Avatar asked Feb 20 '14 09:02

Kundan Atre


People also ask

How do I test my Chrome WebView?

# Open a WebView in DevTools The chrome://inspect page displays a list of debug-enabled WebViews on your device. To start debugging, click inspect below the WebView you want to debug. Use DevTools as you would for a remote browser tab.

What is WebView DevTools?

WebView DevTools is a developer tools to debug WebView in Beta. Recently, Google announced WebView DevTools, which is a new set of on-device debugging tools to diagnose WebView-caused crashes and misbehaving web platform features. Well, WebView DevTools comes included as part of WebView itself.


1 Answers

Try this:

  1. Enable Developer Options in Device (Settings-->About Phone-->Tap 7 times on build number)

  2. Turn on Developer options and Enable USB Debugging (in Developer Options)

  3. Add this line in your custom Application class or in the Activity where the Web View is loaded

    // if your build is in debug mode, enable inspecting of web views

     if (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)) {      WebView.setWebContentsDebuggingEnabled(true);  } 
  4. Open Chrome and type chrome://inspect/#devices and you should see your device in the Remote Target List

  5. Click on inspect to debug it.

Update: You can simplify it like below:

WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG) 
like image 90
Shailendra Madda Avatar answered Sep 22 '22 12:09

Shailendra Madda