Remote debugging on Chrome for Android

A couple of new features in DevTools make remote debugging on Chrome for Android easier to setup: the ADB extension and reverse port forwarding.

The ADB Chrome extension simplifies the process of setting up remote debugging. It provides the following benefits:

  • Bundles Android Debug Bridge (ADB) so you don’t have to install it.
  • No command line interaction required.
  • UI for easily starting and stopping the ADB daemon, and viewing connected devices.

Reverse port forwarding makes it easy to connect Chrome on Android to a web server running on your localhost, something that some network environments make difficult without some DNS tricks.

Using the ADB extension

First, install the ADB Chrome extension from the Chrome Web Store. Click Add to Chrome to install the extension.

Installing extensions from the Chrome Web Store isn’t supported on Windows 8. If you have any problems installing from the Chrome Web Store, seeRemote Debugging on Android for alternate installation instructions.

Once installed, a gray Android menu icon appears in Chrome. To start ADB, click the icon and then click Start ADB.

ADB extension menu

Once ADB has started, the menu icon turns green and displays the number of currently connected devices, if any.

ADB extension menu showing connected devices

Click View Devices to open the about:inspect page that displays each connected device and its tabs. To inspect a tab in DevTools, click the “inspect” link next to its URL.

about:inspect page showing links for device tabs

If you don’t see any connected devices, check that your device is connected to USB, and that USB debugging is enabled in the Chrome for Android settings. For more detailed instructions and troubleshooting steps, see Remote Debugging on Android.

Reverse port forwarding (experimental)

Commonly you have a web server running on your local development machine, and you want to connect to that site from your device. If the development machine and the device are on the same network, this is straightforward. But in some cases, like on restricted corporate networks, this may not be possible without some clever DNS tricks. A new feature in Chrome for Android called reverse port forwardingmakes this simple to do. It works by creating a listening TCP port on your device that forwards traffic over USB to a particular TCP port on your development machine.

To use this feature you will need:

  • Chrome 28 or later installed on your development machine
  • Chrome for Android Beta installed on your device
  • Android Debug Bridge (ADB Chrome extension or full Android SDK) installed on your development machine

To use reverse port forwarding, you need to have your device connected for remote debugging, as described in Using the ADB extension. Then you need to enable reverse port forwarding and add a port forwarding rule for your application.

First, enable reverse port forwarding:

  1. Open Chrome on your development machine.
  2. In about:flags, turn on Enable Developer Tools experiments and restart Chrome.
  3. Open about:inspect. You should see your mobile device and a list of its open tabs.
  4. Click the “inspect” link next to any of the sites listed.
  5. In the DevTools window that opens, open the Settings panel.
  6. Under Experiments, turn on Enable reverse port forwarding.
  7. Close the DevTools window and return to about:inspect.

Then add a port forwarding rule:

  1. Click the “inspect” link again to open DevTools, and open DevTools Settings again.
  2. Click the Port Forwarding tab.
  3. In the Device port field, enter the port number Chrome should connect to on your Android device (defaults to 8080).
  4. In the Target field, append the port number where your web application is running on your development machine.

    Port forwarding tab in DevTools Settings

  5. In Chrome for Android, open localhost:<device-port-number>, where <device-port-number> is the value you entered in the Device portfield (default is 8080).

You should see the content being served by your development machine.