This is a guide for wireless adb debugging flow without needing to connect your device to your PC all the time. I’ve included steps and information to help non-android engineers (e.g. backend engineers, data analysts) setup adb for easier development.
In case you are a seasoned android engineer, jump past the beginner section to “Connect to a device over Wifi”.
In case you are not an android engineer, you most likely don’t have the tools installed or correct settings on your device. Let’s setup them first.
What is adb?
Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps.
Step 1: Installing adb
To install adb on macOS, the easiest way is to use homebrew. Homebrew is a package manager for macOS. If you don’t have homebrew install, use this command to install:
/bin/bash -c "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh]( ))"
To install adb using homebew, run this command
brew install android-platform-tools
For other OS like windows or linux, you can check this guide.
Steps 2: Turning on Developer options
To connect your device to a PC and use adb, we must turn on the Developer options on device. This setting lets you configure system behaviors that help you profile and debug your app.
To turn developer options on, you have to find Build Number option in settings and tap on it 7 times. You can find this option in one of the following locations, depending on your Android version and device brand:
- Android 9 and higher: Settings > About Phone > Build Number
- Android 8 : Settings > System > About Phone > Build Number
- Android 7 and lower: Settings > About Phone > Build Number
Once you do this, you should be able to see Developer options setting at one of the following locations, depending on your Android version and device
- Android 9 and higher: Settings > System > Advanced > Developer Options
- Android 8: Settings > System > Developer Options
- Android 7 and lower: Settings > Developer Options
Step 3: Turning on USB debugging
Before you can use the debugger and other tools, you need to enable USB debugging, which allows adb to recognize your device when connected via USB. To enable USB debugging, toggle the USB debugging option in the Developer Options menu.
Step 4: Connecting your device
Once you have installed adb, turned on developer options and USB debugging, connect your phone via a cable to your PC. As soon as you connect your device, you may see a popup on your devices with the title “Allow USB debugging” showing the RSA fingerprint of your PC, check the “Always trust this computer” option if it is your personal PC, and press Ok.
Step 5: Check the connection
Run the following command to list the devices connected
You should see an output as shown
(If you don’t, that means your device isn’t connected to your PC — check your cable connection)
Output: List of devices attached [Device Name] device
This marks the end of beginner section. Now we begin the steps to connect adb over Wifi.
Connect to a device over Wifi
Connect your device to your PC via a USB cable and ensure both your device and PC are on the same Wifi network. Then run the following command to start adb in TCP/IP mode.
adb tcpip 5555
Now we need to find out the IP address your device has on the wifi network. You can either go to about section of your settings, there in status page you can see your device assigned IP address, or you can run this command which gets your network addresses for wlan0 i.e. wifi network:
adb shell ip -f inet addr show wlan0
This commands prints an network-info output:
Output: 30: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 3000 inet 192.168.1.33/24 brd 192.168.1.255 scope global wlan0 valid_lft forever preferred_lft forever
192.168.1.33 is your device IP on the WIFI network.
Now we run the command to connect to the device IP over 5555 port:
adb connect [IP]:5555
It gives a status output:
Output: connected to [IP]:5555
Disconnect your USB cable and run
adb devices again, you should an output like:
List of devices attached [IP]:
This means your device is now running ADB over wifi on the 5555 port.
In my personal experience, unless your router is restarted or your device restarts, router keeps the device IP same and thus I’ve never had to connect cable for weeks even after disconnecting to the WIFI. I just needed to run
adb connect [Last_IP]:5555 to connect to my device without attaching the cable again.
In case of any error or misbehaviour, run the following:
# Disconnect the device adb disconnect [IP]:5555
# This kills the adb server adb kill-server
# Restart the adb server adb start-server
# Reconnect device via cable and repeat step 6 adb tcpip 5555 adb connect [IP]:5555
Bonus: Installing apk using adb
One of the most basic use-case for a non-android engineer to use adb is to install an apk. To do that one needs to run the following command after ensuring that device is connected:
adb install -r -t -d path_to_apk
The flags -r, -t and -d are to replace existing application, allow test packages and allow version code downgrade respectively.
You can learn more about adb commands by running
adb help or by visiting https://adbshell.com.
Bonus: Presenting device screen on PC
Another major use-case is to present your device screen on PC to share on a zoom meeting. To do this we install another command line utlity by Genymobile called scrcpy
Installing in macOS using homebrew is easy, just run this command:
brew install scrcpy
To present your device, you simply connect your device and run:
To learn more about it’s flags and capabilities, run
scrcpy --help or visit their github page.
Thanks for reading!