Android 幽灵设备 emulator-5554 offline

遇到的问题:

adb devices 出现了个 emulator-5554设置,导致插入安卓设备的时候,执行命令经常遇到 more than one devices错误。

排查过程:

在stackoverflow上找了下,先尝试关闭了所有模拟器,都重启了好多次,还是没效果,排除了是模拟器搞鬼。于是按照网上找到查找5555端口的程序,netstate 和 lsof 过滤下5555端口,定位下pid,最后htop里面去查pid,查到是我之前安装的一个插件导致的。在我的mac上面tabnine插件默认占用了5555端口,导致adb认为是个模拟器,一直在尝试链接。
找到一篇文档http://t.zoukankan.com/jiangu66-p-3184790.html

  • adb 启动就连接5555端口
  • 为何连接叫 emulator-5554 而不是 emulator-5555?
    这是因为缺省emulator的 console 端口是 5554 ( 应该可以用 telnet 连接与 emulator 交互(还没有试验)) , 而adb 的端口是console端口 +1 就是 5555

后面去tabbnie的github上看了看,原来之前就有人遇到过这个问题

https://github.com/codota/TabNine/issues/422 (Why bind port on 5555),tabbnie后面也提供了修改端口的接口,Under tabnine_config.json, set tabnine_hub_port

解决方案:

修改tabbnie的配置文件 tabnine_config.json里面的tabnine_hub_port 默认端口,例如4555。如果你找不到tabnine_config,请搜索。