Debug Chrome on Android devices

Use Chrome DevTools on your computer to inspect and debug web pages open in Google Chrome on an Android device. Kobiton CLI forwards the device’s DevTools connection to a port on your computer, so no virtualUSB connection is required.

This method applies to Google Chrome on Android devices only.

Requirements

Open Chrome DevTools for a device

  1. Create a CLI session on the device. See Create a CLI session.

  2. Open the web page in Google Chrome on the device:

    kobiton device shell "am start -a android.intent.action.VIEW -d <URL> com.android.chrome"

    Replace <URL> with the address of the page to debug.

    The DevTools connection is available only while Chrome is running on the device.

  3. Forward the device’s DevTools connection to port 9222 on your computer:

    kobiton device forward tcp:9222 localabstract:chrome_devtools_remote
    Output
    Listening on 127.0.0.1:9222.

    Keep this command running while you use DevTools.

  4. In Google Chrome on your computer, go to chrome://inspect/#devices.

  5. Make sure Discover network targets is selected.

    localhost:9222 is in the Configure…​ list by default.

  6. Wait for the device to appear under Remote Target. This can take up to about 40 seconds.

    The device’s Chrome version and its open tabs are listed.

  7. Under the tab to debug, click inspect.

    DevTools opens for the page running on the device.

Stop debugging

  1. In the terminal running kobiton device forward, press Ctrl+C.

  2. End the session:

    kobiton session end -s <SESSION_ID>

    Replace <SESSION_ID> with the session ID from step 1 of the previous procedure.

Troubleshooting

No tabs appear under Remote Target

If Remote Target appears with no Chrome version or tabs after about 40 seconds:

  • Make sure Chrome is open on the device.

  • Check that the forward reaches the device. Open http://localhost:9222/json/list in a browser on your computer. The response lists the tabs open on the device.

If the response lists the tabs but chrome://inspect does not, the connection to the device is too slow for chrome://inspect. Use a device with a faster network connection.

The previous device is still listed

After you switch to another device on the same local port, chrome://inspect can continue to show the previous device’s Chrome version and tabs. Reloading the page does not clear them.

Use one of the following:

  • Restart Google Chrome on your computer.

  • Forward the new device to a different local port, for example tcp:9223. Then in chrome://inspect/#devices, click Configure…​ and add localhost:9223.

    The previous device’s heading can remain on the page with no tabs under it.

For command syntax and options, see Kobiton CLI commands.