Member-only story
Remotely debugging Android WebView content
Recently a client told me he was having trouble with some webapages displayed inside an app we made for him but he couldn’t manage to get over it, so he would have liked to be able to debugging web content displayed inside the webview.
It is actually possible to debug live content displayed inside a WebView using the Chrome Developer Tools if your app runs on devices sporting Android 4.4 or later.
In order to do so you will have to:
- Enable web content debugging in your app via code
- connect the test device to a computer (be it a Linux, Mac or Windows one) via USB
- Open Chrome DevTools
- Select the WebView you want to “inspect””
Let’s go in order, first of all you will have to call the static method setWebContentsDebuggingEnabled on the WebView class
WebView debugging does not depend on the state of the
debuggable
flag in the application's manifest. If you want to enable WebView debugging only when the app is debuggable too be sure to test thedebuggable
flag at runtime.
Once the app is compiled and running on your test device:
- connect the device to you…