您的位置:首页 > 其它

使用adb命令连接模拟器,在5037端口未被占用情况下仍报端口错误

2017-01-17 19:13 295 查看
问题:

win7 64位系统使用adb命令连接模拟器,在5037端口未被占用情况下,报以下错误:

   * daemon not running. starting it now on port 5037 *

   CreateProcess failure, error 2

   * failed to start daemon *

   error: cannot connect to daemon

解决方法:

1.将本机C:\WINDOWS\System32下的adb.exe文件复制到C:\Windows\SysWOW64下。

2.将本机C:\WINDOWS\System32下的AdbWinApi.dll文件复制到C:\Windows\SysWOW64下。

解决过程:

第一步:

初一看应该是5037端口被占用了,一个比较常见的错误,于是马上执行命令查看5037端口被谁占用了:

   netstat -ano | finder "5037"

但是神奇的事情发生了,结果是没有任何程序占用该端口。

第二步:

于是执行adb kill-server ,OK,再执行adb start-server,又提示相同的错误了,adb无法在5037端口启动。

第三步:

执行一下adb nodaemon server命令看看什么情况,这是一个比较有用的命令,一般情况下它会告诉我们哪里出问题了

  adb nodaemon server

不幸的是仍然没有提示任何错误

第四步:

检查环境变量配置,没有错误

第五步:

基本排除adb本身的错误,开始定位CreateProcess failure, error 2 这个错误,查到了错误代码:

windows error code 2 means: 2 The system cannot find the file specified. ERROR_FILE_NOT_FOUND

and from the source code this is after a call to CreateProcess() and the file name is given by GetModuleFileName()

已经查证过不是环境配置的问题,所以定位为系统无法启动该文件。

第六步:

 进入C:\WINDOWS\System32目录,检查adb相关文件。都是正确的。

第七步:

复制\System32目录下的adb.exe文件到C:\WINDOWS\SysWOW64 ,再次执行adb devices命令,提示缺失AdbWinApi.dll文件

再将\System32目录下的AdbWinApi.dll文件copy到C:\WINDOWS\SysWOW64,执行adb devices命令成功。

问题扩展:

1.32位系统

   AdbWinApi.dll文件的说明如下:

   If that doesn't work, you will have to extract the .dll to your system directory. By default, this is:

   C:\Windows\System (Windows 95/98/Me)

   C:\WINNT\System32 (Windows NT/2000)

   C:\Windows\System32 (Windows XP, Vista, 7, win 8)

   If you use a 64-bit version of Windows, you should also place the .dll in C:\Windows\SysWOW64\

   所以32位系统应该不需要执行步骤2即可解决,有待验证。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: