Remotely debug Android WebViews

Debug Android WebViews in your native Android apps using Microsoft Edge Developer Tools.

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

Android WebView is not related to Microsoft Edge WebView2.

Summary

  • Turn on Android WebView debugging in your native Android app; debug Android WebViews in Microsoft Edge DevTools.
  • To display the list of the Android WebViews with debugging turned on, go to edge://inspect.
  • Debug Android WebViews in the same way you debug a webpage through remote debugging.

Configure Android WebViews to debug

Android WebView debugging must be turned on within your app. To turn on Android WebView debugging, run the setWebContentsDebuggingEnabled static method on the WebView class.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    WebView.setWebContentsDebuggingEnabled(true);
}

The setting applies to all of the Android WebViews of the app.

Tip

Android WebView debugging isn't affected by the state of the debuggable flag in the manifest of the app. If you want to turn on Android WebView debugging only when the debuggable flag is true, test the flag at runtime.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    if (0 != (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE))
   { WebView.setWebContentsDebuggingEnabled(true); }
}

Open an Android WebView in DevTools

To display a list of the Android WebViews with debugging turned on that run on your device, go to edge://inspect.

To start debugging, under the Android WebView you want to debug, click inspect. Use DevTools in the same way that you use a remote browser tab.

Troubleshoot

If your Android WebViews aren't displayed on the edge://inspect page:

  • Verify that Android WebView debugging is turned on for your app.

  • On your device, open the app with the Android WebView you want to debug. Then, refresh edge://inspect.

Note

Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons Attribution 4.0 International License. The original page is found here and is authored by Meggin Kearney (Technical Writer).

Creative Commons License This work is licensed under a Creative Commons Attribution 4.0 International License.