Skip to content
webtoapkfree

How do I debug an Android WebView app with Chrome DevTools?

To debug an Android WebView in Chrome DevTools, call setWebContentsDebuggingEnabled(true), turn on USB debugging and open chrome://inspect.

GuidesNookesh Karri

Light cover card with the title 'How do I debug an Android WebView app with Chrome DevTools?' in dark text and a green accent bar

To debug an Android WebView app with Chrome DevTools, the app has to call WebView.setWebContentsDebuggingEnabled(true), because WebView blocks DevTools connections by default. Then turn on USB debugging on the phone, plug it into your computer, open chrome://inspect in desktop Chrome and click inspect under your app’s WebView.

That gives you the same Elements, Console and Network tools you use for a desktop site, pointed at the page running inside your app.

What you need before you start

Debugging a WebView in Chrome DevTools needs four things: a phone, a cable, desktop Chrome and an app that allows it.

  • An Android phone on Android 4.4 (KitKat) or later. Chrome’s WebView remote debugging guide starts at that version. Any current phone qualifies.
  • A USB cable that can transfer files. Some cheap cables only charge, and the computer never sees the phone.
  • Chrome on your computer. Edge works the same way, but this guide uses Chrome’s labels.
  • An app build with WebView debugging switched on. This is the step people skip.

Step 1: Turn on WebView debugging in the app

WebView debugging is turned on from inside the app with one static call. The Android debugging guide says your app’s WebView won’t accept Chrome DevTools connections by default, and the call usually goes in the Activity or Application class where the WebView is created.

if (0 != (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE)) {
    WebView.setWebContentsDebuggingEnabled(true)
}

Two details matter here:

  1. It applies to every WebView in the app. You don’t set it per screen.
  2. The manifest debuggable flag doesn’t control it. That’s why the snippet checks FLAG_DEBUGGABLE at runtime. Without the check, your release build ships with debugging on.

Android recommends this conditional check so debugging runs only in development builds. Otherwise anyone with a cable can inspect your app’s pages and storage.

Step 2: Enable USB debugging on the phone

USB debugging lives in Developer options, which Android hides until you unlock it. The developer options page gives the path.

  1. Open Settings > About phone and find Build number. On a Samsung Galaxy S8 or later it sits under Settings > About phone > Software information.
  2. Tap Build number seven times, until you see “You are now a developer!”.
  3. On Android 9 and newer, go to Settings > System > Advanced > Developer Options and switch on USB debugging. Phone makers sometimes move this menu, so use the settings search if it isn’t there.

Step 3: Connect and open chrome://inspect

Chrome DevTools finds the phone through the chrome://inspect page in desktop Chrome. Plug the phone straight into the computer, not through a hub, and keep its screen unlocked.

  1. Open chrome://inspect in Chrome on your computer.
  2. Check that Discover USB devices is ticked.
  3. Look at your phone. The first time, it asks you to allow USB debugging from this computer. Accept it.
  4. Your phone’s model name appears under Remote Target. Until you accept the prompt, the Chrome remote debugging docs say it shows as Offline.

If you already use the command line, adb devices -l is a quick check that the phone is connected. With adb running, the device list fills in even when Discover USB devices is off.

Step 4: Debug the Android WebView in Chrome DevTools

Your app’s WebView shows up under the phone’s name once the app is open on the screen. It’s usually labelled WebView in followed by your package name, for example WebView in com.example.shop. Click inspect below it.

A DevTools window opens for the page inside the app. Four panels do most of the work:

  • Console: red errors from scripts that failed, blocked requests and mixed-content warnings.
  • Network: requests that failed, were blocked or never left the phone.
  • Elements: the live page. Hover an element in DevTools and it highlights on the phone.
  • Toggle Screencast: mirrors the phone’s page in the DevTools window, and clicks become taps.

A real example: your checkout button does nothing in the app but works in Chrome. The Console shows Uncaught TypeError: Cannot read properties of null (reading 'getItem'). That points at localStorage being unavailable, which is one of the causes of a WebView white screen too.

One caution from Chrome’s docs: screencasting lowers frame rates. Turn it off before you judge how smooth the app feels. For speed problems, see why WebView apps feel slower than native.

Why your WebView doesn’t show up in chrome://inspect

A WebView missing from chrome://inspect almost always comes down to one of six causes. Work down this table in order; the first rows are the most common.

What you see Likely cause Fix
Phone listed, no WebView under it The build never called setWebContentsDebuggingEnabled(true) Add the call, rebuild, reinstall
Phone listed, WebView missing even with the call The WebView screen isn’t open Open that screen in the app, then refresh chrome://inspect
Phone shows as Offline You haven’t accepted the prompt on the phone Unlock the phone and tap Allow
No prompt ever appears Phone was asleep or in the wrong USB mode Replug with the home screen showing, keep it awake, set USB mode to PTP
Nothing listed at all Charge-only cable or a USB hub Plug in directly with a cable that can transfer files
Nothing listed on Windows Missing phone driver Install your phone maker’s OEM USB driver

If prompts get stuck, Revoke USB Debugging Authorizations in Developer options resets them. Then reconnect and accept again.

When you can’t change the app’s code

If you made your app with a builder, you may not be able to add the debugging call at all. You can still debug most problems by inspecting the same page in Chrome on the phone.

Open Chrome on the phone, then use the Open tab with url box on chrome://inspect to load your page on the device. Click Inspect next to that tab. You get Console and Network for the same site, on the same phone and network.

A WebView app shows a normal web page, so any error that also happens in Chrome, such as a broken script or a failed API call, shows up here. What it won’t show is behaviour that only exists inside the app: a missing file chooser, blocked pop-ups or a sign-in page that refuses to load in an embedded browser.

The same limit applies to apps made with webtoapkfree.com. Its builder doesn’t promise that every website works in a WebView, and sign-in, downloads, permissions and external links can behave differently than in Chrome. If a page works in Chrome on the phone but not in the app, that difference is your answer, and the file upload and Google sign-in guides cover the usual culprits.

My take on debug builds

Keep two builds from day one: a debug build with WebView debugging on, and the release build without it. When something looks wrong, install the debug build on your phone.

The catch: chrome://inspect needs a cable or adb and a computer next to the phone. It can’t help you with a bug a user reports from a phone model you don’t own. For those, ask for the Android version and a screenshot, then reproduce it on the closest device you have.

FAQ

Why doesn’t my WebView show up in chrome://inspect?

Usually because the app never called WebView.setWebContentsDebuggingEnabled(true). WebView doesn’t allow DevTools connections by default. If the call is there, open the screen with the WebView on the phone and refresh chrome://inspect.

Does android:debuggable turn on WebView debugging?

No. WebView debugging isn’t affected by the manifest debuggable flag. If you want it only in debug builds, check ApplicationInfo.FLAG_DEBUGGABLE at runtime before making the call.

Can I debug a WebView app I didn’t build?

Only if that app turned WebView debugging on. If it didn’t, open the same page in Chrome on the phone and inspect that tab from chrome://inspect instead.

Should WebView debugging stay on in the Play Store version?

No. Android recommends a conditional check so debugging is enabled only in development builds, not in production.

Sources