Android WebView debugging: fixing the chrome://inspect Pending authentication error
Recently I was in a situation where I had to check a problem with a page shown in a WebView inside a native Android app.
For iOS, since I was using a Mac, WebView debugging is fairly simple with Safari's Web Inspector.
That's because once you enable Safari's Develop menu on the Mac and connect the iPhone, you can see the running WebView and debug it right away.
On Android, on the other hand, you have to use the Remote Debugging feature in Chrome DevTools.
I enabled USB Debugging on the Android device, connected it to the Mac over USB, and opened this address in Chrome.
chrome://inspect/#devicesWhen the connection works, the Chrome tabs or WebViews running on the Android device show up in the Remote Target list, and you can debug them through DevTools.
But unlike what I expected, only this message kept showing under the Remote Target area.
Pending authentication: please accept debugging session on the device.The device was recognized, but the debugging session was not starting.

Checking the official docs and fixing it
To solve the problem, I also checked the official Chrome DevTools docs.
The official docs explain how to set up Android remote debugging in this order.
- Enable USB Debugging on the Android device
- Connect it to the PC over USB
- Open chrome://inspect/#devices in Chrome
But I had already done all of these steps, so at first it was hard to figure out what the problem was.
I then explained the situation to an Android developer at my company, and got the advice to check whether adb (Android Debug Bridge) was installed.
My Mac didn't have adb installed, so I installed adb with Homebrew from the terminal.
brew install android-platform-toolsAfter installing, I checked the version with this command in the terminal to make sure it was installed correctly.
adb versionThen I started the ADB server with the start command.
adb start-serverAfter running the command, a popup asking to allow USB debugging appeared on the Android device's screen.

When I chose Allow there, the WebView showed up correctly in DevTools as well, and I could debug it.

In the end, the debugging authentication step wasn't going through correctly because ADB wasn't installed.
What I took away
With iOS, Safari Web Inspector lets you debug a WebView with a fairly simple process, but I learned that on Android, because the connection to the device goes through ADB, a USB debugging authentication step is needed.
In particular, the Pending authentication: please accept debugging session on the device. message kept showing even though I had already allowed USB debugging, so it took me a little while at first to find the cause.
In the end, I learned that Android remote debugging in Chrome DevTools communicates with the device through ADB internally, so if ADB isn't installed, the debugging authentication step may not go through correctly.
If you are setting up Android WebView debugging for the first time, it may also help to check first that ADB is installed correctly.
- #ADB
- #Android
- #Android Debug Bridge
- #chrome://inspect
- #Pending authentication
- #Pending authentication: please accept debugging session on the device.
- #WebView debugging