Android - Connecting to device with adb over wifi

redevill picture redevill · Jan 5, 2015 · Viewed 9.3k times · Source

Context: Nexus 7 Android device (NOT Rooted), Android Studio, Mac OS Yosemite 10.10 Swapping between Eclipse environment and the Android studio appears to have caused the problem, But I don't know how to repair it. All attempts below are after the Eclipse has been shutdown and both computer and device rebooted.

Have seen quite a few S.O. entries but none resolve the intermittent issue of the dreaded 'helpful' message 'unable to connect to 192.168.xx.xx'

It will work successfully sometimes, then "pop" can't connect via wireless Connection. One suggestion I saw was to disconnect the USB after the adb tcpip 5555 command. This worked for me for a while. But not currently!

Have also have tried reboot (computer and device... this has helped before)

Have tried invoking adb tcpip 7612 this alternate port different port This gives me either 'unable to connect to 192.168.xx.xx:5555' OR 'unable to connect to 192.168.xx.xx:7612:7612'

Android docs suggest adb kill-server. And to repeat the steps, Still get the 'helpful' message 'unable to connect to 192.168.0.4'

I have tried specifying that the Nexus use wireless from the Nexus itself (using a terminal app), although I am uncertain if these commands are taking affect as the device is not rooted. setprop service.adb.tcp.port 5555 stop adbd start adbd

Any help in determining what causes the intermittent nature of this connectivity would be greatly appreciated. Thanks

Answer

Your problem seems related to the ADB process started by your IDE. If you want to be sure your ADB connection is working as should and you don't have any error in the commands you are executing I recommend you to use one IntelliJ/Android Studio plugin I've developed to connect your device to your computer over WiFI. Here is the code and here the plugin ready to be used.

In the following gif you can see how it works:

enter image description here