Remote Debugging on Android (Legacy Workflow)

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

Overview

To start debugging, you need:

  • An Android phone or tablet with Google Chrome for Android installed from Google Play.
  • A USB cable to plug in your device. (Windows users will also need to install an appropriate USB device driver.)
  • The Android SDK installed on your development machine.
  • Google Chrome installed on your development machine .
  • 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. On the mobile device, launch Chrome. Open Settings > Advanced > DevTools and check the Enable USB Web debugging option as shown here:
    4. Enable USB Web Debugging in Chrome for Android

    5. 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
    6. Port forwarding using the adb tool

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

    7. On your development machine, open Chrome and navigate to localhost:9222.
    8. 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.
    9. Inspectable pages

    10. 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.