error: cannot connect to daemon at tcp:5037: Undefined error: 0错误解决
最近遇到一次adb启动不起来的情况,报错信息:
1.在输入"adb devices" 或 "adb shell"时提示:
List of devices attached
- daemon not running. starting it now at tcp:5037 *
adb E 03-31 09:30:26 2350 95705 usb_osx.cpp:333] Could not open interface: e00002c5
adb E 03-31 09:30:26 2350 95705 usb_osx.cpp:294] Could not find device interface
error: could not install smartsocket listener: Address already in use
ADB server didn't ACK - failed to start daemon *
error: cannot connect to daemon
2. 于是我尝试“adb kill-server”来重启adb
ulucudeMacBook-Pro:~ ulucu$ adb kill-server
- server not running *
居然adb都没有起来?
3.于是用“Then run "lsof -i tcp:5037"”找一找是不是端口占用的问题:
ulucudeMacBook-Pro:~ ulucu$ lsof -i tcp:5037
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
adb 2308 ulucu 7u IPv4 0x440443a862048a7b 0t0 TCP localhost:5037 (LISTEN)
发现是有的
4.运行“kill 2308”把进程杀掉,再运行“adb devices”
- daemon not running. starting it now at tcp:5037 *
- daemon started successfully *
** daemon still not running
error: cannot connect to daemon at tcp:5037: Undefined error: 0
无果。
5.于是上google搜索,发现网上很多在说是genymotion没有使用android studio的sdk,修改后也无效
6.后来搜索“error: cannot connect to daemon at tcp:5037: Undefined error: 0”
打开sdk目录/platform-tools/source.properties文件,发现版本刚好是文中的25.0.4
于是重新下载platform-tools文件夹覆盖即可。
这个问题其实自己google了半天,但是却总是查出无效重复的结果,原因在于没有很好的思路:
1.应该还原工作环境到最干净的状态,重启电脑并关闭其他无关的软件
2.注意搜索关键字,在重启电脑第一次adb start-server的时候是有输出Daemon
start sucessfully的,只是没有connect上,从第二次开始就都是一样的报错了
3.注意到第一次start-server的时候输出的error: cannot connect to daemon at tcp:5037: Undefined error: 0 报错信息,搜索该句关键字并在stackoverflow上找到对应的问题