adb常用命令

指定特定连接设备

1
2
3
4
$ adb devices
List of devices attached
cf264b8f device
emulator-5554 device

启动/停止 adb

1
2
adb start-server
adb kill-server

获取手机上安装的应用列表

1
adb shell pm list packages

安装/卸载 应用

1
2
adb install APK的路径
adb uninstall APK的包名

清除APK的数据

1
adb shell pm clear 包名

列出前台 Activity

1
adb shell dumpsys activity activities | grep mFocusedActivity

调起指定的Activity/Service,发送指定广播

1
adb shell am start -n com.tencent.mm/.ui.LauncherUI
1
adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -n com.lee.test/.CompleteReceiver

强行停止应用

1
adb shell am force-stop -n 包名

PC与手机互传文件

1
adb pull 手机文件路径 电脑上目录

模拟按键/输入

1
adb shell input keyevent 具体数值

Android 日志

1
adb logcat [<option>] ... [<filter-spec>] ...

查看IMEI号

1
2
3
adb shell
su
service call iphonesubinfo 1

查看系统属性

1
adb shell cat /system/build.prop

屏幕截图并传到电脑端

1
adb shell screencap -p /sdcard/hello.png

录制屏幕

1
adb shell screenrecord /sdcard/lee.mp4

重启机器

1
adb reboot

Monkey 压力测试

1
adb shell monkey -p 包名 -v 500

查看进程

1
adb shell ps

录屏(开始录制)

1
adb shell screenrecord /sdcard/demo.mp4

限制录制时间:

参数: –time-limit

1
adb shell screenrecord  --time-limit 10 /sdcard/demo.mp4

说明:限制视频录制时间为10s,如果不限制,默认180s

指定视频分辨率大小:

1
adb shell screenrecord --size 1280*720 /sdcard/demo.mp4

指定视频的比特率:
参数: –bit-rate

1
adb shell screenrecord --bit-rate 6000000 /sdcard/demo.mp4