adb 常用命令

400 阅读1分钟

查找错误信息

adb shell dumpsys dropbox --print ${newest_time}

模拟输入文本(text)

adb shell input text "hello,world"

过滤日志

通过内容过滤

  adb logcat | grep MyApp
  adb logcat | grep -i myapp #忽略大小写。
  adb logcat | grep --color=auto -i  myapp #设置匹配字符串颜色。更多设置请查看 grep 帮助。

通过标签过滤

adb logcat -s 标签

获取ANR日志

adb bugreport

debug

adb shell am set-debug-app -w com.xxxx.xxxx

adb shell am clear-debug-app

查看指定包名应用内存使用情况

adb shell dumpsys meminfo package

清除应用缓存

adb shell pm clear com.xxxx.xxxx

查看前台 Activity

adb shell dumpsys activity activities | grep mResumedActivity

adb shell "dumpsys activity activities | grep mResumedActivity"

查看所有运行 Running activities

adb shell dumpsys activity activities | sed -En -e '/Running activities/,/Run #0/p'

保存日志到电脑

adb logcat > D:/log.txt 

参考