Drop that embarrassing USB cable when you develop on Android

10 novembre 2012

Are you an Android developer or an Android Hacker? If yes, you certainly use ADB (Android Debug Bridge) to do various things like:

One thing I have noticed is that most developers connect their device to their computer using a USB cable and that sucks because:

Anyway, for those of you who want to connect to your device wirelessly using ADB, I have some good news for you: it is possible and it is easy.

First, let’s talk about how ADB works and then let’s dig into that very straightforward solution (or if you are busy just jump to the second paragraph).

How does ADB work?

ADB is a tool that includes three components:

As you can guess, there is a two way communication going on between the server and the daemon. That communication happens over a medium which can be of two sorts: USB or TCP. Aha, you get it know? If we want to connect to our device wirelessly then we just have to switch the transport mode from USB to TCP. Let’s do that!

The solution: Switching ADB transport mode from USB to TCPIP

  1. Before switching to TCP, we’ll need to grab the IP address of the device. To do that, we can either go to the phone settings or use the command line tool netcfg

    adb shell netcfg

  2. Once you are in possession of the device’s IP address (let’s say it’s:, you can switch to TCP mode by doing: 

    adb tcpip
     One thing to remember is that you can only choose a port number within the range of [5555…5585] (the reason being that ADB Server only works with these ports). So for instance you could do: 
    adb tcpip 5555

  3. Stop ADB Server (we’ll restart it later by issuing any ADB command): 

    adb kill-server

  4. Set ADBHOST to your IP address: 

    ADBHOST= adb devices

  5. Make sure your device is connected

the last part of the last command should print the device that you are trying to connect to.

What to do if you don’t have a USB cable from the begining?

If you don’t have a USB cable at first, then you need to root your device first then run the following command on your device: 

setprop service.adb.tcp.port 5555

Then you need to stop/restart the adb daemon: 

stop adbd
start adbd

How to switch back to USB transport mode? 

adb usb

But there is one caveat

This only works since Android 4.0 (ICS). If you have to develop/hack on other Android versions then you need to root that device (in order to use ADB in unsecure mode).

That’s all folks, I hope that you are now hacking Over The Air 🙂