I thought there was a way to test your applications in development over Wi-Fi. Is this possible?
I\'d love to be able to untether my phone and develop wirelessly.
To complete the answer of @usethe4ce, if you have more than one device or emulators, the adb tcpip 5555
will give error: more than one device/emulator
.
In this case you need to give the serial number of the desired device:
adb devices
List of devices attached
33001229 device
emulator-5554 device
adb -s 33001229 tcpip 5555
adb connect xxx.xxx.xxx.xxx:5555
adb tcpip 5555
adb connect <DEVICE_IP_ADDRESS>:5555
adb devices
1- For this I am considering you have already installed the latest version of Android studio. If not you can download it from here.
2 - You can set the platform tools path in environment variable (optional).
3 - Make sure your device and pc connected to same network.
plug in the data cable from pc to device.
Now, type adb tcpip 5555
remove data cable.
Then type adb connect 192.168.43.95
here 5555 is the port number and 192.168.43.95 is the ip address of the mobile device you can get id address from the mobile settings .
Then go to About device and go to status you can see the ip address of the device.
You can connect multiple device from different ports which can give ease in development.
Or you can go to this link for brief description with screenshots. http://blogssolutions.co.in/connect-your-android-phone-wirelessly-by-adb
I wrote a simple script for Windows:
Step 1. Make a batch file with the below commands and call the file wifi_dedug.bat and copy the below contents:
adb tcpip 5555
pause
adb shell "ip addr show wlan0 | grep 'inet ' | cut -d' ' -f6|cut -d/ -f1" > tmpFile
pause
set /p ip= < tmpFile
@echo %ip%
del tmpFile
@echo %ip%
adb connect %ip%
pause
Step 2. connect your device to pc.
Step 3. start batch file (key enter when requested)
Step 4. disconnect your device and deploy/debug via wifi.
If you want to enable wireless adb on the device without connecting with a USB cable at all (root required):
Since you already have the terminal opened, you can find the IP address of the device:
ip addr show
Then in your debugging environment run command:
adb connect ip.of.the.device
This will make the device to be listed as any other emulators you might have. Note that the TCP will stay opened until you reset the device. You might also want to install a Wi-Fi Keep Alive app if you often experience disconnects.
Remember to close the TCP when connecting to public networks if you want to feel safe. You can do the following or simply restart the device:
I wrote a shell script which can let you debug an Android device via Wi-Fi.
Here is the code:
#!/usr/bin/env bash
#Notice: if unable to connect to [ip]:5555,
#try adb kill-server then try again.
adb shell ip route > addrs.txt
#Case 1:Nexus 7
#192.168.88.0/23 dev wlan0 proto kernel scope link src 192.168.89.48
#Case 2: Smartsian T1,Huawei C8813
#default via 192.168.88.1 dev eth0 metric 30
#8.8.8.8 via 192.168.88.1 dev eth0 metric 30
#114.114.114.114 via 192.168.88.1 dev eth0 metric 30
#192.168.88.0/23 dev eth0 proto kernel scope link src 192.168.89.152 metric 30
#192.168.88.1 dev eth0 scope link metric 30
ip_addrs=$(awk {'if( NF >=9){print $9;}'} addrs.txt)
echo "the device ip address is $ip_addrs"
echo "connecting..."
rm addrs.txt
adb tcpip 5555
adb connect "$ip_addrs"