When developing Android applications, at some point you might want to deploy your app on a real Android device. Every app developer knows, that in this case you activate the “developer options” on your Android device, connect it to your laptop via USB port and you are good to go!
However, sometimes you don’t want to be tied to your computer when doing so. There are a number of reasons why connecting via USB is not always the best solution:
- You need to move your phone around while debugging - for instance you are developing some application that uses GPS or one of your motion sensors
- You have an older device, where the USB port has a loose connection (looking at you, Samsung!)
- You have no more free USB ports on your laptop and you forgot your USB hub. (looking at you, Apple!)
The solution to this is pretty simple. All you need are 2 commands and a WiFi network where your laptop and your Android device can see each other.
Make sure your device is connected via USB (don’t worry, we can remove the cable shortly). Then type in your console:
adb tcpip 5555
Find out the IP address or hostname of your Android device, then connect to it. for example:
adb connect pixel-6or
adb connect 192.168.x.y
That’s it - you’re done!
$ adb tcpip 5555 restarting in TCP mode port: 5555 $ adb connect pixel-6 connected to pixel-6:5555
You can now use all adb features like
chrome://inspect, etc. as long as you are in your WiFi range.
This will work until you reboot your Android device. For a persistent solution, please visit the linked Stack Overflow thread. The persistent solution requires a rooted Android device, though.