在Ubuntu 20.04(WSL2)上运行:
➜ ~ adb --version
Android Debug Bridge version 1.0.41
Version 33.0.1-8253317
Installed as /home/eliya/dev/Android/platform-tools/adb
跑步
➜ ~ adb devices
adb W 04-28 16:43:11 20145 20145 network.cpp:149] failed to connect to '172.23.160.1:5037': Connection timed out
* cannot start server on remote host
adb: failed to check server version: cannot connect to daemon at tcp:172.23.160.1:5037: failed to connect to '172.23.160.1:5037': Connection timed out
跑步
➜ ~ adb start-server
adb W 04-28 16:47:17 21475 21475 network.cpp:149] failed to connect to '172.23.160.1:5037': Connection timed out
* cannot start server on remote host
error: cannot connect to daemon at tcp:172.23.160.1:5037: failed to connect to '172.23.160.1:5037': Connection timed out
但当我以root用户身份运行它时,它似乎工作得很好:
➜ ~ sudo adb devices
List of devices attached
XXXXXXXXXXXXXX device
我怎样才能让adb
在没有sudo权限的情况下工作?
更新1
运行adb -H localhost ...
看起来还可以,我在这里遗漏了什么?
更新2
在Windows中运行:
PS C:\Users\coeli> adb start-server
然后在WSL2中(挂起一段时间,然后失败):
➜ ~ adb devices
List of devices attached
* cannot start server on remote host
error: cannot connect to daemon at tcp:172.23.160.1:5037: Connection timed out
2条答案
按热度按时间ryhaxcpt1#
如果你想让WSL能够与运行在Windows中的
adb
服务器通信,你必须启动服务器,使其监听所有接口,而不仅仅是默认接口。如果您想使用默认端口5037以外的端口,也可以在其中放置一个
-P
,如下所示:如果你仍然有问题,仔细检查你的Windows防火墙。然而,因为这是所有本地接口的东西,这不应该是一个因素,在大多数安装。
dldeef672#
我想我可能已经找到了一个解决这个问题的方法。在我的例子中,这个问题是由于没有正确安装sdkmanager引起的。我使用openjdk11而不是openjdk8,openjdk8是sdkmanager正确运行所必需的。无论如何,按照www.example.com的https://gist-github-com.translate.goog/georgealan/353a548814fe9b82a3a502926c7a42c6?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=en-US&_x_tr_pto=wapp#passo-4%C2%BA应该可以让你在不使用sudo命令的情况下启动和运行它。文章是针对ReactNative的,但你不需要按照整个过程来做