Connecting to Android Device with ADB over WiFi made (a little) easy

If you are an Android developer, I am 100% sure you might already be frustrated with debugging your App with ADB while being connected through a USB cable. If you didn’t know already, you can connect to your Android Device with ADB over Wifi. But, it still requires you to ‘do stuff’. So, I wrote a Shell Script to make this a one-click process and I’ll be sharing the same in this post.

Note: I wrote this script on a mac which means this sould run on other linux based machines with small or no modifications. Windows users can use ideas from this post to implement it themselves.

Image for post
Image for post
Photo by Farzad Nazifi on Unsplash

But first, how to even do it manually?

Follow the steps given below:

  • Enable USB debugging in the Android device.
  • Connect the device to the computer via a USB port.
  • Press allow in the permissions dialog if prompted.
  • Find out where the adb binary is present on your computer. For a mac, it is generally present in
  • Browse to that location and open a terminal window.
  • Type below command to check if your device was successfully connected.
  • The output will look similar to
Image for post
Image for post
  • If you can’t figure out which one is the intended device, type below command to print device information.
  • If your device is not visible make sure you didn’t miss any of the above points. Redo the above steps again if that solves your problem.
  • In the output of the above command, the first word is the device id. We will use that to connect to the Android device over WiFi.
  • Make sure the Android device and the computer are connected to the same WiFi network.
  • Type below command to restart the adb in tcpip mode for the device.
  • The output will look like this
Image for post
Image for post
  • Find out the local IP address of the Android device. You can find this information by pressing/long-pressing the WiFi icon in the quick settings drop-down and then clicking the WiFi network you are connected to.
  • Type below command to connect to the device over WiFi.
  • The output will look like this
Image for post
Image for post
  • If the command ran successfully, you can now disconnect the USB cable and enjoy debugging over WiFi.

Too many steps!

Now we will automate the above process (a little) using a shell script.

The mighty but tiny Shell Script

The script is pretty self-explanatory. Just copy the script in the folder where adb is present, name the file adbwificonnect and use as mentioned in the file.

How does it work?

  • First, the available devices are listed down.
  • Then the device id of the chosen device is extracted using the awk command. For option -a, all the available devices are chosen.
  • For every chosen device, adb is restarted in tcpip mode.
  • To find the IP address of the device, ifconfig command is run in the device’s shell using adb and the device id, and inet addr value of wlan0 network interface is extracted.
  • Then the device is connected using adb and the IP address.

Happy debugging!

Written by

Software Engineer (little 'kotlin' lover) and free time Photo Clicker.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store