最新消息:20210917 已从crifan.com换到crifan.org

【已解决】Mac中adb用WiFi连接安卓出错:failed to connect to 5555 Connection refused

Mac crifan 1833浏览 0评论
折腾:
【已解决】给自动测试工具项目代码中加上判断安卓手机设备是否已连接的逻辑
之后,去调试,报错:
[201218 09:27:56][DevicesMethods.py 1904] Try connect Android device: adb connect 192.168.31.84:5555
[201218 09:27:57][DevicesMethods.py 1907] console output: failed to connect to '192.168.31.84:5555': Connection refused
    
[201218 09:27:57][DevicesMethods.py 1904] Try connect Android device: adb connect 192.168.31.84:5555
[201218 09:27:57][DevicesMethods.py 1907] console output: failed to connect to '192.168.31.84:5555': Connection refused
    
[201218 09:27:57][DevicesMethods.py 1904] Try connect Android device: adb connect 192.168.31.84:5555
[201218 09:27:57][DevicesMethods.py 1907] console output: failed to connect to '192.168.31.84:5555': Connection refused
    
[201218 09:27:57][AppCrawler.py 42 ] Android device 192.168.31.84:5555 not connected after 3 retry !
但是此处Mac终端中adb可以看到设备的:
 adb devices
List of devices attached
2e2a0cb1    device
orga4pmzee4ts47t    device
192.168.31.84:5555    device
所以有点奇怪。
failed to connect to  5555 Connection refused
adb failed to connect to  5555 Connection refused
android – ADB : unable to connect to 192.168.1.10:5555 – Stack Overflow
adb kill-server
adb start-server
试试
 adb kill-server
 adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
  adb devices
List of devices attached
2e2a0cb1    device
orga4pmzee4ts47t    device
-》看来adb没有实时刷新,都是假象。重启后原来是没有tcpip连接过。
所以重新试试
 adb tcpip 5555
error: more than one device/emulator
估计是多个设备导致的。去指定设备
 adb -s orga4pmzee4ts47t tcpip 5555
restarting in TCP mode port: 5555
继续:
 adb connect 192.168.31.84:5555
failed to connect to '192.168.31.84:5555': Connection refused

发现刚才搞错设备了。。。
重新弄:
  adb -s 2e2a0cb1 tcpip 5555
restarting in TCP mode port: 5555
 adb connect 192.168.31.84:5555
connected to 192.168.31.84:5555
即可连接上了。
【总结】
此处虽然PC(Mac)端adb能看到wifi设备:
 adb devices
List of devices attached
...
192.168.31.84:5555    device
但是实际上是:过期的,无效的。
所以
adb connect 192.168.31.84:5555
会报错:
failed to connect to '192.168.31.84:5555': Connection refused
解决办法:
重启adb,重新配置。
重启:
adb kill-server
adb start-server
确认设备是USB有线已连接:
 adb devices
List of devices attached
2e2a0cb1    device
。。。
注意此处是多个USB设备连接
所以指定对应设备切换成tcpip,即WiFi模式:
 adb -s 2e2a0cb1 tcpip 5555
restarting in TCP mode port: 5555
如果只有一个设备,则可以:
adb tcpip 5555
最后再去connect连接WiFi设备:
 adb connect 192.168.31.84:5555
connected to 192.168.31.84:5555
即可。
附录:
已回复帖子
macos – ADB Connection refused from Mac to Android – Stack Overflow

转载请注明:在路上 » 【已解决】Mac中adb用WiFi连接安卓出错:failed to connect to 5555 Connection refused

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.186 seconds, using 23.38MB memory