android studio无法发现设备


title: android studio无法发现设备
tags: 新建,模板
grammar_cjkRuby: true

遇到问题as看不到设备,但是adb devices可以看到设备。如下所示。

enter description here

enter description here

非常困惑,为什么adb devices能看到,而as不行。难道用的不是同一个adb吗?
在stackover上查了各种方法尝试都没有效果。包括重启,kill-adb,重装as等。
后来忽然发现一个路径可以找出问题,点击右下方的device,会弹出错误 adb inintialiazed error,并且提示我们可以去看错误日志。在这里插入图片描述

于是去help-show log in finder打开日志,发现这么一行WARN,可以看到在连接localhost的时候超时了。问题在于localhost被dns解析到30.129.144.64的ip下,这是不对的,所以我就在host里配了localhost 和 127.0.0.1的映射,重启as,搞定。

原因是连内网的时候自动给电脑配了dns服务器,解析localhost的时候根据内网dns服务器走到了别的ip。

2019-01-03 15:59:02,927 [st Monitor]   WARN -            #com.android.ddmlib - Unable to open connection to: localhost/30.129.144.64:5037, due to: java.net.ConnectException: Operation timed out 

终于明白了,

猜你喜欢

转载自blog.csdn.net/litefish/article/details/85703973