While developing an Android app, many of the times you need to test your app on actual devices. For that, you need to connect your device through a wire. But I feel, wired is weired.

The Alternative to that can be going with a wireless solution.

Temporary solution

Step 1 : Connect your laptop/computer and smartphone on the same WiFi network.

Step 2 : Get your smartphone’s local IP address. You can install this for knowing your local IP address if you have no clue.

Step 3 : Connect your smartphone using USB cable.

Step 4 : Run these commands one after another.

adb tcpip 5000
adb connect YOUR_SMARTPHONE_S_IP_ADDRESS:5000

Step 5 : Disconnect your smartphone from USB cable.

For switching back to USB mode

adb usb

Permanent solution

This solution is similar to the previous one. Here we are trying to do the same thing with the help of shell scripting.

Follow these steps once and you are done.

Step 1 : Create a file called con inside the home[~] directory. and paste these commands inside it.

#!/bin/bash

adb disconnect
adb tcpip 5000
sleep 3
adb connect $1:5000

Step 2 : Make the file executable.

chmod a+x con

Now every time you boot your computer, you have to follow till 3rd step from the temporary solution section. Then run only one command.

./con YOUR_SMARTPHONE_S_IP_ADDRESS

After that, disconnect and enjoy!