查看设备日志
adb logcat
输出日志到文件
adb logcat>android.log
logcat 有缓存,如果仅需要查看当前开始的 log,需要清空之前的
adb logcat -c && adb logcat
查询某个APP的日志
adb logcat | grep TrafficMonitor
adb logcat | grep -i TrafficMonitor
根据标签来过滤日
adb logcat -s TrafficMonitor
启动ADB服务
adb start-server
终止服务
adb kill-server
进入ADB运行环境
adb shell
ADB命令帮助
adb help
查看ADB版本
adb version
root权限重启ADB
adb root
将system分区重新挂在为可读写分区,此命令在操作系统目录时很重要
adb remount
安装APK(-r 覆盖安装, -d 解决低版本问题,-s 安装apk到SDK卡)
adb install test.apk -r
卸载APK
adb uninstall com.jifen.qukan
查看APP所有相关信息
adb shell dumpsys package com.ss.android.article.lite
查看APP路径
adb shell pm path com.ss.android.article.lite
查看apk的版本信息
adb shell dumpsys package com.ss.android.article.lite | grep version
查看当前运行的APP包名和Activity
adb shell dumpsys window w | grep mCurrent
启动APP的Activity
adb shell am start -n com.ss.android.article.lite/com.ss.android.article.lite.activity.SplashActivity
输出安装包路径
adb shell pm path com.ss.android.article.lite
清除应用数据
adb shell pm clear com.ss.android.article.lite
获得应用的启动时间,可以很方便地获取应用的启动时间
adb shell am start -W com.ss.android.article.lite/com.ss.android.article.lite.activity.SplashActivity
启动service,am的-n参数表示组件,-a参数表示命令,-a后面的参数为manifest中定义的service的action
adb shell am startservice -a "android.intent.action.CALL"
发送广播
adb shell am broadcast -a "android.intent.action.AdupsFota.WriteCommandReceiver"
查看APP进程相关信息
adb shell ps
查看指定包的APP进程信息
adb shell ps | grep com.ss.android.article.lite
KILL进程
adb shell kill pid Number
查看某个APP内存使用情况
adb shell dumpsys meminfo | grep com.ss.android.article.lite
查看单个应用程序的最大内存限制
adb shell getprop | grep heapgrowthlimit
获取单个应用的电量消耗信息
adb shell dumpsys batterystats | grep com.ss.android.article.lite>> xxx.txt
python historian.py xxx.txt > xxx.html
上面的输出结果可读性不强,可以使用google的historian.py将其转化成HTML文件
跑monkey命令,运行过程中,应用程序会不断切换画面,按照选定的不同级别反馈信息,还可以看到执行过程报告和生成的事件。测试应用的稳定性时很实用
adb shell monkey -v -p com.ss.android.article.lite 500 -v
查看设备分辨率
adb shell dumpsys window | grep Surface
adb shell wm size
查看SDK版本
adb shell getprop | grep version
查看手机型号信息
adb shell getprop | grep product
获取序列号,获取到的序列号即为adb devices列出来的序列号
adb get-serialno
查看链接设备
adb devices
查看WIFI密码
adb shell cat data/misc/wifi/*.conf
查看WIFI的MAC地址
adb shell cat /sys/class/net/wlan0/address
查看后台services信息
adb shell service list
查看系统当前内存占用,为综述
adb shell cat /proc/meminfo
查看设备内存占用
adb shell top
查看系统设置的闹钟
adb shell dumpsys alarm
查看系统的wakelock,不合理的使用wakelock会导致系统耗电加剧
adb shell dumpsys power
拷贝文件目录到设备
adb push <local>...<remote>
从设备拷贝文件/目录到本机
adb pull [-a] <remote>...<local>
查看设备文件目录
adb shell ls [-al]
进入文件夹
adb shell cd <folder>
备注:adb shell 进入设备shell后,其操作命令与linux一直,具体就不追叙了