![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
adb devices ------查看连接设备
adb install apk路径 ------安装apk
adb install -r apk路径 ------覆盖安装apk
adb uninstall com.xx ----- 卸载apk
adb shell pm clear com.xx ------清除app数据
adb shell dumpsys window windows | findstr "Current"
------获取包名及当前页面的activity
aapt dump badging apk路径
------查看apk包的packageName、versionCode、applicationLabel、launcherActivity、permission等各种详细信息,比较常用的命令
如下
package: name='com.xxx' versionCode='90700' versionName='9.7.0'
![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
adb shell dumpsys判断设备屏幕和网络状态等
adb shell dumpsys
查看设备锁屏或黑屏状态
adb shell dumpsys window policy|findstr mScreenOnFully
若为true,即为点亮状态 若为false,即为黑屏状态
查看网络连接状态
adb shell dumpsys wifi |findstr "Wi-Fi is "
查看包信息 Package Information
adb shell dumpsys package
查看内存使用情况Memory Usage
adb shell dumpsys meminfo
adb shell dumpsys display | findstr DisplayDeviceInfo
其他常用参数命令
adb shell dumpsys activity---------------查看ActvityManagerService 所有信息
adb shell dumpsys activity activities----------查看Activity组件信息
adb shell dumpsys activity services-----------查看Service组件信息
adb shell dumpsys activity providers----------查看ContentProvider组件信息
adb shell dumpsys activity broadcasts--------查看BraodcastReceiver信息
adb shell dumpsys activity intents--------------查看Intent信息
adb shell dumpsys activity processes---------查看进程信息
![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
adb shell am获取APP启动时间
am(ActivityManager) 可用于启动时间测试(实际APP测试不能以此作为判断标准 )
adb shell am start -W com.xx/.home.activity.HomeActivity
![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
adb shell wm查看模拟屏幕分辨率和密度
命令查看屏幕尺寸
#方法一
修改及重置size和desity
adb shell wm size 1080x1920
#设置分辨率1080x1920
adb shell wm size reset
#重置分辨率
adb shell wm density 480
#设置density 480
adb shell wm desity reset
#重置desity
![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
adb shell monkey稳定性测试
adb shell monkey
常用组合
adb shell monkey -p com.xx --ignore-crashes --ignore-timeouts --ignore-security-exceptions --pct-syskeys 0 --throttle 200 500000 >sdcard/huaweimonkey0725.txt
参数解释:
其中com.xx指包名,如何获取adb logcat | findstr Displayed
200 为延迟时间--throttle,单位毫秒
500000为事件数
0为系统事件百分比 --pct-syskeys
--ignore-crashes 忽略应用 crash 报错,不指定该参数时,
应用出现 crash,monkey 会自动停止发送事件,指定该参数后,
mongkey 会在 crash 后也一直发送事件,知道所有事件发送完成
--ignore-timeouts 忽略超时导致的错误,即ANR的错误
--ignore-security-exceptions 忽略许可错误
--monitor-native-crashes 监控由 C/C++ 代码引起的 crash
--ignore-native-crashes 忽略由 C/C++ 代码引起的 crash
--kill-process-after-error 当出现错误后杀掉应用的进程
--hprof 指定该选项后,monkey会在发送事件完成后生成性能
报告,报告一般存放于/data/misc目录下
如何停止monkey
adb shell
ps | grep monkey
返回来的第一个数字,即是monkey的进程号
shell 7772 185 277516 22244 ffffffff 4010a58c S com.Android.commands.monkey
kill 命令结束进程继续输入:
kill 7772 查到的进程号
如何获取monkey异常日志
adb shell monkey执行完查看崩溃日志 【Android】抓取log(anr)
第一步:adb shell
第二步:cd /data/anr(如果有anr目录继续执行第三步,如果没有会提示没有此目录,那就不需要再去找traces.txt文件了)
第三步:ls(查看存在的traces.txt 文件)
第四步:Ctrl+C退出,然后输入adb pull /data/anr/traces.txt E:\ 把traces.txt文件导入到E盘
ANRs (“Application Not Responding”),意思是”应用没有响应“。
![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
adb shell pm查看应用相关信息
adb shell pm 相关命令
adb shell pm list packages ------列出所有应用
adb shell pm list packages -s ------列出系统应用
adb shell pm list packages -3 ------列出第三方应用
adb shell pm list packages test
adb shell pm list packages |findstr test ----比如要查看包名包含字符串 test 的应用
![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
adb logcat查看日志信息
adb logcat
adb logcat | findstr Displayed
------adb获取当前页面的activity adb logcat 主要功能 logcat (四类log buffer是main,radio,system,events)
adb logcat -v time > logcat.txt //默认是-b main -b system
adb logcat -v time -b main //main log
adb logcat -v time -b radio //radio log
adb logcat -v time -b system //system log
adb logcat -v time -b events
![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
adb shell dumpsys耗电测试
一、测试APP是否过量耗电
adb shell logcat -v time 导出log中sending alarm行不含待测应用包名。若存在,则需要关注type为0和2的sending alarm是否频繁,若出现多次则说明有可能会造成过量耗电。
二、在低电耗模式和应用待机模式下进行测试
目的: 为确保用户获得良好的体验,您应在低电耗模式和应用待机模式下全面测试您的应用。
在低电耗模式下测试
使用 Android 6.0(API 级别 23)或更高版本的系统映像配置硬件设备或虚拟设备。
在应用待机模式下测试
使用 Android 6.0(API 级别 23)或更高版本的系统映像配置硬件设备或虚拟设备。
![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
adb shell ps查看进程信息
adb shell ps
执行完adb shell ps
USER PID PPID VSIZE RSS WCHAN PC NAME
fu0_a349 31658 481 2405608 180692 ffffffff 00000000 S
USER: 进程的当前用户;
PID : 毫无疑问, process ID的缩写,也就进程号;
PPID :process parent ID,父进程ID
VSIZE :virtual size,进程虚拟地址空间大小;
RSS : 进程正在使用的物理内存的大小;
WCHAN :进程如果处于休眠状态的话,在内核中的地址;
PC :program counter,
NAME: process name,进程的名称
今天介绍的adb命令可根据个人需求自行封装脚本,下节会分享monkeyscript脚本应用,敬请期待!
可参考偷偷告诉你ADB命令葵花宝典【一键截图和录屏】
![e967bb3ae1cb9965dcf05d1b4a8e8807.png](https://img-blog.csdnimg.cn/img_convert/e967bb3ae1cb9965dcf05d1b4a8e8807.png)
猜你喜欢
偷偷告诉你ADB命令葵花宝典【adb运行原理及WiFi连接】
偷偷告诉你ADB命令葵花宝典【一键截图和录屏】
Android数据存储
iOS数据存储
《如何高效学习》读书笔记
读书篇---麦肯锡问题分析与解决技巧(下)
读书篇---麦肯锡问题分析与解决技巧(上)
如果想要更多人看见,请点击在看哦