首页 > 解决方案 > ADB TCP port automatically changes to 5037

问题描述

I am connecting wireless over TCP to a rooted samsung android device via ADB. By following instructions in this.

Everything seems just fine but it seems that sometimes Android Studio cannot connect by the port 5555 so it changes it to 5037.

Which causes the connection to get refused, so when I try to connect using adb connect 192.168.2.109:5555 , I get:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *
unable to connect to 192.168.2.109:5555: Connection refused

Solution of this problem: I have changed TCP port in my android device to be 5037 and it works perfectly

My Question is: why is the TCP port in Android Studio changing?

Information: OS: Ubuntu 18.04.1 LTS, Android Studio: 3.1.4

标签: androidandroid-studiotcpadb

解决方案


一切似乎都很好,但似乎有时 Android Studio 无法通过端口 5555 连接,因此将其更改为 5037。

这不是这里真正发生的事情。你对流程的理解是完全错误的。

3个部分adb

  • adbd守护进程,它在每个设备或模拟器实例中作为后台进程运行。
  • adb服务器,它在您的开发机器上作为后台进程运行。服务器处理多路复用并管理adb客户端和adb守护程序之间的整体通信。
  • adb客户端(与服务器相同的二进制文件adb),它也在您的开发机器上运行。

adb tcpip <PORT>命令更改adbd设备上守护程序的配置。 adb connect <IP>:<PORT>命令告诉服务器通过 TCPIP 网络而不是默认的 USB 连接adb连接到远程守护进程。adbd

最后* daemon not running. starting it now on port 5037 *消息是指正在启动的本地adb服务器实例。端口5037用于adb客户端和服务器之间的通信,它与或命令adb指定的端口无关。adb tcpipadb connect

那么你为什么Android Studio中的TCP端口会改变?问题没有答案,因为 Android Studio 没有改变任何东西。从unable to connect to 192.168.2.109:5555您可以看到它确实正在尝试5555按照指示使用该端口。


推荐阅读