Debugging Android Applications over WiFi

I was recently working on an application that used the device’s accelerometer to extract information from the way that a person walks. While I was aware that it was possible to debug applications over WiFi, until now it wasn’t something that was absolutely needed. If I needed to get up and move a bit for an application, I had just used a longer USB cable. With this application it was essential that I want the way that I normally do. There was no way to do that with a USB cable connected to the device. Instead, it was necessary to use WiFi debugging.

Another reason why one might want to debug over WiFi simply to charge a device; some computers output a disappointing amount of current over their USB ports. For some applications, the device’s battery could continue to diminish as it is being used while connected to a computer. Using a higher wattage charge may be necessary if only to maintain the current battery amount.

For devices running Android 10 and earlier, making the network connection is easy. Start by making a USB connection. To ensure that there is a connection established use the following command.

adb devices

You should see your device listed. If it is, the next step is to establish a connection over the network. Ensure that your device and the computer being used for debugging are on the same network and subnet. Enable network debugging on your computer using the following command.

adb tcpip 5556

Here 5555 is the port number that will be used. You can use a different port number if you like. Using the IP address of your android device, you can establish a connection with the following command.

adb tcpip 192.168.1.97:5556

If all goes well, a message will be received that the device is connected. The device can now be physically disconnected from the computer. It will remain connected to the computer over the network connection.

Within Android Studio or adb if left connected the device will show twice.

Both devices showing within Android Studio

The device will continue to show as a connection until manually disconnected. To manually disconnect use the following command.

adb disconnect