When testing, the most straightforward way to install and run an application on your device is to use a cable and connect your phone to your computer. But what if you would like to connect to your device wirelessly? This would be needed for example if you want to test an app that uses a cable to communicate with other hardware, such as an external keyboard. Here’s a guide on how to test Android over wifi (rooting your device is NOT required).
Steps to make your device available via Wi-Fi
- Make sure ADB (Android debug bridge) is installed. It’s part of the Android SDK Platform Tools and can be downloaded from here.
- In any case, you need to connect your device physically via a cable first. There is no way around it: Connect your device to your desktop via cable
- Enable “Developer Options” and “USB debugging” on your device. You can find a guide on how to do that here.
adb tcpip 5555in a terminal -> The device will start listening for connections on port 5555
- Look up the device IP address by executing
adb shell netcfgor
adb shell ifconfigwith Android 6.0 and higher;
- You can disconnect the USB now;
adb connect <your device IP>:5555. This connects to the server we set up on the device in step 3;
adb devicesand you will see that the device is available remotely through ADB now
How to switch back to USB cable mode?
To switch back to USB cable mode, run
If you have more than one device, you can specify the device with the
adb -s <your device IP>:5555 usb.
Important: Leaving the option enabled is dangerous, anyone in your network can connect to your device in debug. Do it only when connected to a trusted Wi-Fi and remember to disconnect it when done!
On some devices, such as emulators (AVDs) you can do the same thing even if you do not have a USB cable:
What if I can’t connect via a cable at all?
First of all: Establishing a wifi connection without any cable only works on a routed device. If your device is not rooted and you can’t connect via a cable, you are out of luck. There are Android security constraints that won’t allow you to connect.
But if your device is rooted, you can do the following:
- Install a terminal app on the device (like Android Terminal Emulator)
- Then enter following commands into the terminal:
su setprop service.adb.tcp.port 5555 stop adbd start adbd
- Use this command to find the IP address of your device:
ip addr show
- On your desktop, open a terminal and execute:
adb connect <your device IP from step 3>
- check via ADB devices if your device is listed
Important: For safety reasons, remember to close the TCP port. You can do the following or simply restart the device:
su setprop service.adb.tcp.port -1 stop adbd start adbd
To test Android over wifi there are a few steps needed, however it’s totally possible. Even though the most common solution is still to test devices via cable, especially because it’s the most secure way of testing. Android testing tools like Repeato will help with that.