12

I am debugging an Android app that usually crashes when I plug into an Arduino it is supposed to be communicating with. Consequently, I need to get a wireless connection to the device's logcat, which is what brought me to ADB over TPC as seen on the Android developers webpage.

The recommended process is:

C:\Users\User> cd AppData\Local\Android\sdk\platform-tools
C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb kill-server
C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb tcpip 5555
restarting in TCP mode port: 5555
C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb connect 10.20.5.160:5555

However, the typical response is:

unable to connect to 10.20.5.160:5555: cannot connect to 10.20.5.160:5555: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)

I could not consistently get a connection between a PC and mobile device. Over the course of three weeks using several networks and devices, I could only connect two times out of an agonizing many attempts.

I have dug deep into the posted questions on stackoverflow and tried literally every recommended alteration to getting an adb connection, from using an Android Studio plugin to forwarding ports to trying several other ports to toggling my device's internet. I still could not get a connection more than a fraction of a percent of the time.

When I look at the network state of my device after adb tpip <port>, I find no evidence of the device trying to look for a connection:

C:\Users\User\AppData\Local\Android\sdk\platform-tools> adb shell
j3ltevzw:/ $ netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 ::ffff:10.20.5.160:4214 ::ffff:173.194.196.188: ESTABLISHED
udp     4288      0 adb shell ip -f inet addr show wlan0:68          10.20.5.1:67            ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State           I-Node Path
  ...    ...   ...        ...         ...                   ...
  ...    ...   ...        ...         ...                   ...

Also, when I try to ping my device, I usually get:

C:\Users\Benjamin\AppData\Local\Android\sdk\platform-tools> ping 10.20.5.160

Pinging 10.20.5.160 with 32 bytes of data:
Reply from 10.20.5.232: Destination host unreachable.
Reply from 10.20.5.232: Destination host unreachable.
Reply from 10.20.5.232: Destination host unreachable.
Reply from 10.20.5.232: Destination host unreachable.

Ping statistics for 10.20.5.160:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)

What I am looking for is a process or file that can be run and consistently open a tcp adb connection, or at least explain what about my setup is invalid. Ideas?

Update 1:

I have started a bounty on this question. I feel like the problem with the ADB software used to make connection for debugging is two fold:

  1. adb tcpip <port> does not always invoke the mobile device to listen on the specified port

  2. adb connect <ip>:<port>, I am assuming, is not given permission by the network to connect; I am not a networking expert, but the fact that pinging a device returns "destination host unreachable" seems a little off

I will award the first person to find a successful solution. Seeing that having an ADB USB connection gives a user access to both the mobile device's and host's terminal, there really is no excuse for a connection not to be able to be made between the two.

Update 2:

I have recently had more success in connecting to the ADB as well as receiving successful pings at my school network. Note at this network connects are insecure and the host and mobile devices where on separate subnetworks. Any idea why these conditions would work over my secure network at home that uses only one subnet?

3
  • Can any of the problems with the ADB be a result of the firewall on either my devices or my network router? Commented Mar 19, 2018 at 0:38
  • The ip you posted doesn't look like a local network ip.. They usually start with 192.168.*.*? How you got that ip?
    – riyaz-ali
    Commented Mar 20, 2018 at 4:49
  • The IP I am using is the one found under my phone settings at About Phone > Status > IP address as well as the local address returned by the adb shell and terminal emulator on my phone. The IP examples above were from a remote location I was a week earlier, but my home IP follows the pattern you describe now. Commented Mar 20, 2018 at 5:08

4 Answers 4

7
+50

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.

10
  • I appreciate your help, but this is pretty much what I have been doing the past couple months (as described in the process above). Would using my laptop as a hotspot possibly make networking to the phone easier? Commented Mar 20, 2018 at 5:23
  • Which version of android are you using? and on what device?
    – riyaz-ali
    Commented Mar 20, 2018 at 5:29
  • SM-J320V running Android Nougat 7.1.1 Commented Mar 20, 2018 at 5:32
  • I was able to connect to my mobile device when it was connected to the hotspot on my laptop. Commented Mar 20, 2018 at 5:34
  • I'll give you credit for now unless someone can get it to work on any network. Commented Mar 20, 2018 at 5:52
1

I found a solution that works for me, but I feel it shouldn't necessary and it may not applicable for everybody else with these issues, so its still not quite what I was aiming for.

Anyways, after seeing riyaz-ali suggest what an IP address I should be for using a mobile hotstop through a phone, I realized any network complications would be solved if I was the network, so I connected my mobile device to the mobile hotspot on my laptop.

Instant ping responses and immediate ADB connection with the popularly suggested commands.

1

Just found myself in the same situation. Had no problem yesterday but today couldn't connect.

Solution was simple, I realized that today I'm connected to VPN which obviously makes me belonging to a different network.

So, disconnecting and connection to the same Wi-Fi solved the trouble.

1
  • I had to face the same issue over many days. The usggestion by Ivan solved my problem. I just disconnected the mobile divice from W-fi and then re-connected . It worked!
    – J.Koriya
    Commented Apr 9, 2023 at 4:34
0

I had a similar problem. IF I was wirelessly connected via ADB to my phone, when I started my VPN with the killswitch setting enabled, the ADB program crashed. By deactivating the killswitch setting and then restarting my computer, I can use the VPN and the ADB at the same time without any problem.

Not the answer you're looking for? Browse other questions tagged or ask your own question.