简体   繁体   English

未连接 USB 电缆时,ADB over TCP/IP 无法正常工作

[英]ADB over TCP/IP not working without USB cable connected

I can connect to my smartphone with ADB using a usb cable, I'm also able to connect over tcp/ip to the same smartphone with adb connect 192.168.1.110 while the usb cable is still connected.我可以使用 USB 电缆通过 ADB 连接到我的智能手机,我也可以通过 tcp/ip 连接到同一个智能手机,使用 adb connect 192.168.1.110,而 USB 电缆仍然连接。

But, as soon as I disconnect the cable, I loose the tcp/ip connection, the device appears to be "offline" (as result to "adb devices" command) and I cannot reconnect over network until I re-connect the cable.但是,一旦我断开电缆连接,我就断开了 tcp/ip 连接,设备似乎处于“离线”状态(“adb devices”命令的结果)并且在重新连接电缆之前我无法通过网络重新连接。

My steps are (this way it works) :我的步骤是(这样工作):

  1. connect the usb cable连接 USB 电缆
  2. adb kill-server adb 杀死服务器
  3. adb tcpip 5555亚行 tcpip 5555
  4. adb connect 192.168.1.110 (here it connects succesfully!) adb connect 192.168.1.110(这里连接成功!)
  5. disconnect usb cable => I loose network connection to the smartphone断开 USB 电缆 => 我与智能手机的网络连接断开

If after step 3 I disconnect the cable, the step 4 doesn't work (port 5555 closed)如果在第 3 步之后我断开了电缆,则第 4 步不起作用(端口 5555 关闭)

It seems like adbd daemon is running ONLY when the cable is connected.似乎 adbd 守护程序仅在连接电缆时运行。

AS my device is not rooted I don't find any way to force adbd daemon to start without connecting the usb cable.因为我的设备没有 root,所以我找不到任何方法来强制 adbd 守护进程在不连接 USB 电缆的情况下启动。

Any idea?任何的想法?

[UPDATE] I just tried to scan the smartphone for tcp port opened and I found that as soon as I run the command: adb tcpip 5555 the scanning found the port 5555 opened but as soon as I disconnect the usb cable, I run again the scan and the port 5555 is found to be closed This confirm that as soon as I disconnect the usb cable don't know why but adb stop responding on port 5555 or the daemon itself get killed or similar [更新] 我只是试图扫描智能手机的 tcp 端口是否打开,我发现只要我运行命令:adb tcpip 5555 扫描发现端口 5555 打开但是一旦我断开 USB 电缆,我再次运行扫描并发现端口 5555 已关闭这确认,一旦我断开 USB 电缆,不知道为什么但 adb 停止响应端口 5555 或守护进程本身被杀死或类似

[UPDATE] I just did the same steps on another Android device (an asus tablet) and it works perfectly, when I disconnect the cable, the tcp port remain opened, so the issue is not with the steps I'm following but with something else [更新] 我只是在另一台 Android 设备(华硕平板电脑)上执行了相同的步骤,它运行良好,当我断开电缆连接时,tcp 端口保持打开状态,所以问题不在于我遵循的步骤,而是一些问题别的

[UPDATE] I found other posts with similar issue, this is one of them: adb connection by wifi getting killed when a new USB attached/detached , unfortunately I cannot do what he says as my smartphone is not rooted and I'm am in the same situation of comment by Osama in that post [更新] 我发现了其他有类似问题的帖子,这是其中之一: 连接/断开新 USB 时,通过 wifi 的 adb 连接被杀死,不幸的是,我无法按照他说的做,因为我的智能手机没有扎根,我在Osama 在该帖子中的评论情况相同

Bellow commands allows you always get 5555 as default port number, try this out波纹管命令允许您始终获得 5555 作为默认端口号,试试这个

Make sure you have wifi configured as "auto connect", also set always allow the adb from net work under developers manul确保您已将 wifi 配置为“自动连接”,并在开发人员手册下设置始终允许来自网络的 adb

adb root
adb remount
adb shell setprop persist.service.adb.enable 1
adb shell setprop persist.adb.tcp.port 5555


adb reboot

You probably don't have The ADB Server running.您可能没有运行 ADB 服务器。

With the USB cable connected,连接 USB 电缆后,
do:做:
adb kill-server && adb start-server && adb tcpip 5555 && adb connect 192.168.1.110

Once Successfully Connected, You can then Disconnect the Cable.成功连接后,您可以断开电缆连接。

NOTE : on running adb devices , the device name is now of the format IP:PORT as opposed to the initial Alphanumeric string.注意:在运行adb devices ,设备名称现在采用IP:PORT格式,而不是初始字母数字字符串。

Firstly connect your device and check if it's connected or not RUN首先连接您的设备并检查它是否已连接 RUN

adb devices

then RUN然后运行

adb tcpip 5555

now disconnect your device usb cable and go to the settings and find out the IP Address of your phone and RUNn现在断开您的设备 USB 电缆并转到设置并找出您手机和 RUNn 的 IP 地址
adb connect your_phone_ip_address adb 连接 your_phone_ip_address

eg. adb connect 192.168.1.102

replace with your own ip and check it with adb devices if it's connected or not if it's not working then the problem must be something else替换为您自己的 ip 并使用 adb devices 检查它是否已连接如果它不工作则问题一定是其他问题

I'm also testing on a Honor phone.我也在荣耀手机上测试。 I found a solution to solve this problem.我找到了解决这个问题的方法。 You can try to turn on Allow ADB debugging in charge only mode and turn off Always prompt when connecting to USB .您可以尝试开启Allow ADB debugging in charge only mode并关闭Always prompt when connecting to USB It should fix the problem.它应该解决问题。

Here is the reference for the solution.这是解决方案的参考

Hello I can solve problem你好我可以解决问题

First of all connect your device with cable (usb debbuging) click on allow on phone if it asks about debugging首先,用电缆连接您的设备(USB 调试),如果它询问调试,请单击手机上的允许

Now open cmd现在打开cmd

type cd 'Location of scrcpy'键入 cd 'scrcpy 的位置'

than type the following比输入以下内容

adb tcpip 5555亚行 tcpip 5555

If it asks you again to do adb tcpip 5555 do it again如果它再次要求您执行 adb tcpip 5555 再执行一次

adb connect <'device-ip-adress'> adb connect <'device-ip-address'>

Disconnect the device by removing the cable通过移除电缆断开设备连接

scrcpy -s <'device-ip-adress'> scrcpy -s <'device-ip-adress'>

Done!完毕! Problem Solved问题解决了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM