ADB常用命令集

181 阅读2分钟

记录日常常用的adb命令,以备随时查看。

1. adb reboot,重启设备
2. adb devices,获取设备列表及设备状态
3. adb get-state,获取设备的状态
4. adb install <APK Path>,用于安装,加 -t 允许安装 test apk,加 -r 代表替换
5. adb uninstall <package>,用于卸载
6. adb push <FilePath A> <FilePath B>,将A地址上的文件推到B地址
7. adb shell,进入设备的shell环境
8. adb shell input keyevent <Code>,使用相关按键功能,例如:4代表返回
9. adb shell pm list <package>,获取到一些安装在 Android 设备上得应用信息
10. adb shell pm clear <package>,清除APP缓存
11. adb shell df,查看磁盘占用
12. adb shell top,查看设备 cpu 占用
13. adb shell top|grep <package_name>,实时监听程序进程的变化
14. adb shell ps|grep <package_name>,查看package_name程序进程 
15. adb shell am start -n <package>/<package>.MainActivity,启动应用
16. adb shell am start -W <package>/<package>.MainActivity,启动时长
17. adb shell getprop,获取系统信息(build type查看系统开发或用户版本),加 | grep build 进行过滤
18. adb -s <deviceName> shell,进入指定设备的shell环境
19. adb logcat,在cmd窗口查看手机的Log日志
20. adb bugreport,获取relase rom  anr log 信息 
21. adb logcat -v time -b all >.\\logcat.log,将日志输出到当前路径下的logcat文件中
22. adb get-serialno,获取设备的序列号
23. adb shell dumpsys input > .\input.txt,打印系统输入信息
24. adb shell dumpsys window -a > .\window.txt,打印系统当前window信息
25. adb shell dumpsys activity -a > .\activity.txt,打印系统当前activity信息
26. adb shell settings put system screen_off_timeout 1000,设置一秒息屏
27. adb shell am start -n <package>/leakcanary.internal.activity.LeakActivity,打开 leak 页面,需要先 root
28. adb shell 进去,执行 ls -al 查看文件权限
29. dumpsys power 与 cat /sys/power/wake_lock,查看阻止锁屏原因
30. adb shell settings put global window_animation_scale 1.25,设置动画速率,默认为:1
31. adb shell settings put global transition_animation_scale 1.25,设置动画速率,默认为:1
32. adb shell settings put global animator_duration_scale 1.25,设置动画速率,默认为:1
33. adb shell settings get global yd_setup_complete,查看 yd_setup_complete 属性值
34. adb shell settings put global yd_setup_complete 1,修改 yd_setup_complete 属性值为 1