Remote Debugging on Android (Legacy Workflow)

This document describes the legacy workflow for remotely debugging Chrome for Android.

Overview

To start debugging, you need:

1. Install the Android SDK

The Android Developer Tools (ADT) bundle provides you with the Android SDK out of the box. Once you've downloaded the ADT, unzip it to a directory on your system (e.g "Downloads").

You will initially see two sub-directories in the extracted folder - eclipse and sdk. To communicate with an Android device, you use the Android Debug Bridge (adb), a command-line tool included in Platform Tools (<sdk>/platform-tools/).

For convenience, add Platform Tools to your PATH environment variable. If on Mac, run the following command from your terminal: export PATH=$PATH:/<path-to-SDK>/platform-tools/.

2. Enable USB debugging on your device

In order to debug over USB, you need to setup your Android device for development. Enable USB debugging on your device then system to detect your device as mentioned in the guide.

To enable USB debugging:

  • On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development.
  • On Android 4.0 and newer, it's in Settings > Developer options.
  • On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.
USB debugging settings in Developer options

3. Connect your device via USB

  1. Connect your mobile device to the development machine using a USB cable.
  2. Ensure your device is listed as available by issuing the adb devices command. If not, please check that you have USB debugging enabled on your device.
  3. Issue the following command in the terminal or console on your development machine to enable port forwarding:
    adb forward tcp:9222 localabstract:chrome_devtools_remote
  4. This one line of code will be something you Google for and copy-paste again, so let's repeat it with a larger font this time:

    adb forward tcp:9222 localabstract:chrome_devtools_remote

    Note: If you get a "device not found" error, run the adb kill-server command to resolve.

    Port forwarding using the adb tool
  5. On your development machine, open Chrome and navigate to localhost:9222.
  6. You will be presented with the set of thumbnails for pages currently open in tabs on your mobile Chrome. Choose the page you would like to debug.
  7. Inspectable pages
  8. You can now start debugging and profiling mobile content in the DevTools on your development machine.

See Debug your Application for tips on getting started debugging your mobile application.