二 、 adb的使用方法

上一章节讲述了adb如何下载和安装,接下来说下adb的使用

1. USB链接手机与电脑,安装驱动正常, window+r 输入 cmd ,打开控制台,执行 adb  devices ,出现如下错误:

C:\Users\lizy>adb devices

adb devicesadb server is out of date.  killing...

ADB server didn't ACK* failed to start daemon *error: unknown host service


2. 原因:

adb的端口(5037)被占用了。至于这个5037端口,可以参考本博客另外 一篇文章:

http://blog.csdn.net/liranke/article/details/4999210

在这个文章里,详细说明了adb的原理及其源码分析。

3. 解决方法:

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


C:\Users\lizy>netstat -ano | findstr "5037"
  TCP    127.0.0.1:5037         0.0.0.0:0              LISTENING       8516
  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\lizy>tasklist | findstr "8516"
sjk_daemon                        8516 Console                    1     3,071 K

哦,原来是sjk_daemon进程占了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
sjk_daemon                     963 Console                    1      3,071 K
tasklist.exe                  1260 Console                    1      5,856 K


将这个进程kill掉:
C:\Users\lizy>taskkill /f /pid 963

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


再运行adb devices,又遇到如下问题,真是一波三折啊。。

 解决方法:

电脑上安装 豌豆荚 就好了。具体是什么原理,没有去细究,若有小伙伴知道原因,可以评论下,互相学习。

查看当前运行的包名和Activity:

1.杀掉其他进程后,启动指定app

2.使用adb shell dumpsys window | findstr mCurrentFocus 查看指定app 的包名的启动avtivity

1.做monkey测试,并保持到本地

adb shell monkey -p com.nb.buling --throttle 300 -s 123456 -v -v -v 100000>D:\android\monkey_log\v2.txt

 2.查操作日志,并保持到本地

adb logcat -v time>d:\android\logcat1.txt


原文:https://blog.csdn.net/liranke/article/details/42524851?utm_source=copy 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自www.cnblogs.com/kekouwen/p/9995599.html