How to Connect to Android With Adb Over Tcp

No Consistent Way to Connect ADB over TCP

Try starting from scratch and setup ADB-over-tcp following steps below:

  1. Turn off USB debugging on your device and turn it on again (just to reset).
  2. Kill the ADB server on your PC using adb kill-server
  3. Connect your device to the PC using the USB cable and type adb devices. This will automatically restart the ABD server again.
  4. Enter adb tcpip 5555 on your PC terminal. This will switch the adbd daemon on your device to tcp-ip mode.
  5. Disconnect your device from USB. Now connect your device to the same wireless network as your PC, either the same wi-fi or use your phone as a hotspot.
  6. Determine your phone's ip. You can do this in the wi-fi settings on your phone. If you are using your phone as hotspot, then generally your ip should be 192.168.43.1 (not required but most of the time it's the same).
  7. Connect to ADB via tcp using adb connect <IP>

This should hopefully connect your device to your pc via tcp-ip.

Use adb over tcpip in Android Studio?

After some testing Android Studio already supports this. You just need perform the following ADB commands, and now you can see the logcat and even wirelessly load your application. No USB cable needed!

From: http://developer.android.com/tools/help/adb.html#wireless

$ adb tcpip 5555
restarting in TCP mode port: 5555

Finding out IP address of Android device prior to running Android Oreo:

Settings -> About tablet -> Status -> IP address. Remember the IP address, of the form #.#.#.#.

Finding out IP address of Android device running Android Oreo

Settings -> Wi-Fi -> -> IP address

Connect adb host to device:

$ adb connect #.#.#.#
connected to #.#.#.#:5555

How can I use adb over WiFi?

  • Connect Android phone and host machine to same WiFi network
  • Connect Android phone to host machine using USB cable (to start with)
  • Run adb tcpip 5555 from a command prompt
  • Run adb shell "ip addr show wlan0 | grep -e wlan0$ | cut -d\" \" -f 6 | cut -d/ -f 1" to obtain the phone's IP address
  • Disconnect USB cable and run adb connect <ip_address>:5555

You can now view logcat output by running adb logcat or by viewing the Android Monitor tab within Android Studio.

Enable adb debug over TCP/IP on Android AOSP

Found the solution.

I don't actually need to change AOSP code at all. All I need is to boot the device with the USB-C cable and do the following:

$ adb shell
hikey960:/ $ su
hikey960:/ # setprop persist.adb.tcp.port 5555
hikey960:/ # exit
hikey960:/ $ exit
$ adb reboot
$ adb connect 192.168.196.77:5555
connected to 192.168.196.77:5555

(after reboot don't forget to remove the USB-C cable!)

So, in other words, we were setting the wrong prop. All props that need to persistent across reboot are prefixed with persist.

I hope it help if anyone fall in the same situation.

Thanks for the replies!



Related Topics



Leave a reply



Submit