No Consistent Way to Connect ADB over TCP
Try starting from scratch and setup ADB-over-tcp following steps below:
- Turn off USB debugging on your device and turn it on again (just to reset).
- Kill the ADB server on your PC using
adb kill-server
- Connect your device to the PC using the USB cable and type
adb devices
. This will automatically restart the ABD server again. - Enter
adb tcpip 5555
on your PC terminal. This will switch theadbd
daemon on your device to tcp-ip mode. - 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.
- 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). - 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
How to Remove All Debug Logging Calls Before Building the Release Version of an Android App
Difference Between a View'S Padding and Margin
How to Set the Text Color of Textview in Code
Get Screen Width and Height in Android
Android and Xmpp: Currently Available Solutions
Android Fatal Signal 11 (Sigsegv) At 0X636F7D89 (Code=1). How Can It Be Tracked Down
Sharedpreferences.Onsharedpreferencechangelistener Not Being Called Consistently
Do Fragments Really Need an Empty Constructor
Android Completely Transparent Status Bar
How to Read Contacts on Android 2.0
How to Create Custom Ratings Bar in Android
How to Implement Onfragmentinteractionlistener
How to Increase Heap Size of an Android Application
Getting an Issue While Checking the Dynamically Generated Checkbox Through List View
Background Task, Progress Dialog, Orientation Change - Is There Any 100% Working Solution
Automatically Accept All Sdk Licences
Illegalstateexception: Can Not Perform This Action After Onsaveinstancestate With Viewpager