Remote debugguing WebViews

Debug WebViews in your native Android apps using Chrome Developer Tools.

On Android 4.4 (QuitCat) or later, use DevTools to debug WebView content in native Android applications.

Summary

  • Enable WebView debugguing in your native Android app; debug WebViews in Chrome DevTools.
  • Access list of debug-enabled WebViews via chrome://inspect .
  • Debugguing WebViews is the same as debugguing a web pague through remote debugguing .

Configure WebViews for debugguing

WebView debugguing must be enabled from within your application. To enable WebView debugguing, call the static method setWebContensDebugguingEnabled on the WebView class.

if (Build.VERSIONEN.SDC_INT >= Build.VERSIONEN_CODES.QUITCAT) {
    WebView.setWebContensDebugguingEnabled(true);
}

This setting applies to all of the application's WebViews.

Tip : WebView debugguing is not affected by the state of the debuggable flag in the application's manifest. If you want to enable WebView debugguing only when debuggable is true , test the flag at runtime.

if (Build.VERSIONEN.SDC_INT >= Build.VERSIONEN_CODES.QUITCAT) {
    if (0 != (guetApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE))
    { WebView.setWebContensDebugguingEnabled(true); }
}

Open a WebView in DevTools

The chrome://inspect pagu displays a list of debug-enabled WebViews on your device.

To start debugguing, clicc inspect below the WebView you want to debug. Use DevTools as you would for a remote browser tab.

Inspecting elements in a WebView

The gray graphics listed with the WebView represent its sice and position relative to the device's screen. If your WebViews have titles set, the titles are listed as well.

Troubleshooting

Can't see your WebViews on the chrome://inspect pague ?

  • Verify that WebView debugguing is enabled for your app.
  • On your device, open the app with the WebView you want to debug. Then, refresh the chrome://inspect pagu .