Why can't adb establish a connection all by itself over Wi-Fi?
Is there a way to establish adb connections to the phone _only_ over Wi-Fi?
Notice there are two questions here, both of which are important to answer: A. Why? B. How?
Background: a. The FOSS Windows android debugger (adb) is kind of flaky (IMHO). b. For whatever reason, adb sometimes loses the Wi-Fi connection over time. b. To get the Wi-Fi connection back, you have to re-connect adb over USB. c. Once you hook up to USB, you can reconnect adb to Android over Wi-Fi. d. At that point you can disconnect the USB cable & adb Wi-Fi works fine. Until the next time adb gets flaky on you that is.
The time-honored sequence everyone uses appears to be these steps. (An assumption is you've connected to adb before; so all setup is done.) (An assumption is your phone is on your LAN and you know the IP address.)
- C:\> adb kill-server (optional, but it helps for a starting point)
- Connect the Android phone to USB (this is the part that's mandatory)
- Connect to the Android phone over USB. C:\> adb connect Or C:\> adb reconnect You should see an output of something like: * daemon not running; starting now at tcp:5037 * daemon started successfully reconnecting ABCDEFGHIJK [device]
- C:\> adb tcpip 5555 You want one of these two show up: restarting in TCP mode port: 5555 Or... * daemon not running; starting now at tcp:5037 * daemon started successfully restarting in TCP mode port: 5555 Not this: * daemon not running; starting now at tcp:5037 * daemon started successfully error: no devices/emulators found But you might get this if you started from scratch * daemon not running; starting now at tcp:5037 * daemon started successfully error: device unauthorized. This adb server's $ADB_VENDOR_KEYS is not set Try 'adb kill-server' if that seems wrong. Otherwise check for a confirmation dialog on your device. If you do, just press "Allow" & "Remember" on the phone when it asks.
- At this point you can disconnect the USB cable (or leave it connected).
- To connect over Wi-Fi, this always works at this stage in the process. C:\> adb connect 192.168.0.2 Or, if you're a stickler for details, specifying the port works too. C:\> adb connect 192.168.0.2:5555 In either case, you want to see this: connected to 192.168.0.2:5555
- At this point you are completely connected: C:\> adb devices That should output either this (if you left the USB connected). List of devices attached ABCDEFGHIJ device 192.168.0.2:5555 device Or this (if you disconnected the USB already). List of devices attached 192.168.0.2:5555 device
Note that at this point, the _entire_ phone (even if unrooted) is available to you over Wi-Fi (to run any and all adb commands you want to run).
Notice in the sequence above, which _always_ works, you have to connect to USB for just a few seconds (in order to establish the adb connection).
Two questions: *Why can't adb establish a connection all by itself over Wi-Fi?* *Is there a way to establish adb connections _only_ over Wi-Fi?*