adb端口被占以及一些报错的解决

来源:互联网 发布:淘宝运费险退换货流程 编辑:程序博客网 时间:2024/06/16 07:08

adb的端口(5037)被占用了。

在cmd窗口:
C:\Users\>adb nodaemon server
cannot bind 'tcp:5037'


C:\Users\>netstat -ano | findstr "5037"
  TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       8621
  TCP    127.0.0.1:5037         127.0.0.1:59163        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:59164        TIME_WAIT       0
  TCP    127.0.0.1:5037         127.0.0.1:59167        TIME_WAIT       0
  ......
C:\Users\>tasklist | findstr "86216"
lt_demo
                        8621 Console                    1     3,071 K

是lt_demo进程占了adb的端口。

C:\Users\lizy>tasklist




Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0 Services                       0          24 K
System                                  4 Services                        0       1,128 K
lt_demo                                 863 Console                    1      3,071 K
tasklist.exe                            1260 Console                   1       5,856 K


干掉这个占用我们adb端口的进程:
C:\Users\>taskkill /f /pid 863

如果这个命令提示无权限,去windows的“任务管理器”中“进程”窗口,找到这个进程,将它干掉。

再启动adb。


C:\Users\>adb devices
List of devices attached
adb server version (31) doesn't
* daemon started successfully *
4df0b93c4bc330f5        device

adb启动成功。


有的时候项目build的时候会报如下错误,都和adb相关:

1.报错: 
BUILD FAILED 
D:\workspace\xxxx\build.xml:144: The following error occurred while executing this line: 
D:\workspace\xxxx\build.xml:271: Unable to delete file D:\workspace\ganji\tmp\proguard\tmp.jar 
解决: 
已经开了一个模拟器了,无法重新编译,必须关闭一个。


2.报错: 
The connection to adb is down, and a severe error has occured. 
解决: 
cmd跳到sdk tools文件路径下 
adb kill-server 
然后再adb start-server 

3.报错: 
The connection to adb is down, and a severe error has occured.
You must restart adb and Eclipse.
Please ensure that adb is correctly located at 'D:\adt-bundle-windows-x86_64-20140624\sdk\platform-tools\adb.exe' and can be executed.
解决: 
方法1.cmd中adb kill-server,然后adb -startserver 
方法2.方法1不管用,那么在任务管理器中杀死adb.exe,然后重启Eclipse。 
方法3.方法1和2都不管用请查看对应路径的platform-tools文件夹中是否有adb.exe.

0 0