记一次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”这一句发现
    https://stackoverflow.com/questions/43131020/adb-cannot-connect-to-daemon-at-tcp5037

    打开sdk目录/platform-tools/source.properties文件,发现版本刚好是文中的25.0.4
    于是重新下载platform-tools文件夹覆盖即可。