Android---adb的常见命令操作
来源:互联网 发布:徐州网络推广学校 编辑:程序博客网 时间:2024/05/22 00:03
Android开发中比较常用的adb命令。
1.adb shell dumpsys meminfo + 包名
查看该包名应用的内存
2.adb shell top -m + 数字
查看应用内存占用率,其中数字为返回的应用数量,从高到低排序
3.adb shell回车
cd /sys/devices/system/cpu/cpu0/cpufreq回车
cat cpuinfo_cur_freq
查看当前CPU的主频(貌似需要一定的访问权限)
4.adb install <apk路径>
安装apk到手机/虚拟机
5.adb logcat
抓取设备的log信息,可以自行添加过滤条件,详细的可以参见这篇文章
http://www.hanshuliang.com/?post=32
这里“引用”一些常见的吧
1. 解析 adb logcat 的帮助信息
在命令行中输入 adb logcat --help 命令, 就可以显示该命令的帮助信息;
- octopus@octopus:~$ adb logcat --help
- Usage: logcat [options] [filterspecs]
- options include:
- -s Set default filter to silent.
- Like specifying filterspec '*:s'
- -f <filename> Log to file. Default to stdout
- -r [<kbytes>] Rotate log every kbytes. (16 if unspecified). Requires -f
- -n <count> Sets max number of rotated logs to <count>, default 4
- -v <format> Sets the log print format, where <format> is one of:
- brief process tag thread raw time threadtime long
- -c clear (flush) the entire log and exit
- -d dump the log and then exit (don't block)
- -t <count> print only the most recent <count> lines (implies -d)
- -g get the size of the log's ring buffer and exit
- -b <buffer> Request alternate ring buffer, 'main', 'system', 'radio'
- or 'events'. Multiple -b parameters are allowed and the
- results are interleaved. The default is -b main -b system.
- -B output the log in binary
- filterspecs are a series of
- <tag>[:priority]
- where <tag> is a log component tag (or * for all) and priority is:
- V Verbose
- D Debug
- I Info
- W Warn
- E Error
- F Fatal
- S Silent (supress all output)
- '*' means '*:d' and <tag> by itself means <tag>:v
- If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS.
- If no filterspec is found, filter defaults to '*:I'
- If not specified with -v, format is set from ANDROID_PRINTF_LOG
- or defaults to "brief"
adb logcat 命令格式 : adb logcat [选项] [过滤项], 其中 选项 和 过滤项 在 中括号 [] 中, 说明这是可选的;
选项解析 :
-- "-s"选项 : 设置输出日志的标签, 只显示该标签的日志;
--"-f"选项 : 将日志输出到文件, 默认输出到标准输出流中, -f 参数执行不成功;
--"-r"选项 : 按照每千字节输出日志, 需要 -f 参数, 不过这个命令没有执行成功;
--"-n"选项 : 设置日志输出的最大数目, 需要 -r 参数, 这个执行 感觉 跟 adb logcat 效果一样;
--"-v"选项 : 设置日志的输出格式, 注意只能设置一项;
--"-c"选项 : 清空所有的日志缓存信息;
--"-d"选项 : 将缓存的日志输出到屏幕上, 并且不会阻塞;
--"-t"选项 : 输出最近的几行日志, 输出完退出, 不阻塞;
--"-g"选项 : 查看日志缓冲区信息;
--"-b"选项 : 加载一个日志缓冲区, 默认是 main, 下面详解;
--"-B"选项 : 以二进制形式输出日志;
输出指定标签内容 :
"-s"选项 : 设置默认的过滤器, 如 我们想要输出 "System.out" 标签的信息, 就可以使用adb logcat -s System.out 命令;
- octopus@octopus:~$ adb logcat -s System.out
- --------- beginning of /dev/log/system
- --------- beginning of /dev/log/main
- I/System.out(22930): GSM -91
- I/System.out(22930): SignalStrength issssssssss : -91
- I/System.out(22930): GSM -91
- I/System.out(22930): SignalStrength issssssssss : -91
- I/System.out(22930): Supervisor Thread
- I/System.out(22930): Got run mode
(2) 过滤项解析
过滤项格式 : <tag>[:priority] , 标签:日志等级, 默认的日志过滤项是 " *:I " ;
-- V : Verbose (明细);
-- D : Debug (调试);
-- I : Info (信息);
-- W : Warn (警告);
-- E : Error (错误);
-- F: Fatal (严重错误);
-- S : Silent(Super all output) (最高的优先级, 可能不会记载东西);
过滤指定等级日志 : 使用 adb logcat 10 *:E 命令, 显示 Error 以上级别的日志;
- octopus@octopus:~$ adb logcat *:E
- Note: log switch off, only log_main and log_events will have logs!
- --------- beginning of /dev/log/main
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- E/dalvikvm( 756): GC_CONCURRENT freed 1809K, 27% free 19489K/26695K, paused 16ms+5ms, total 109ms
- E/WifiHW ( 441): wifi_send_command : SCAN ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- E/dalvikvm( 756): GC_CONCURRENT freed 1820K, 27% free 19490K/26695K, paused 16ms+3ms, total 102ms
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
过滤指定标签等级日志 : 使用 adb logcat WifiHW:D *:S 命令进行过滤;
-- 命令含义 : 输出10条日志, 日志是 标签为 WifiHW, 并且优先级 Debug(调试) 等级以上的级别的日志;
--注意 *:S : 如果没有 *S 就会输出错误;
- octopus@octopus:~$ adb logcat WifiHW:D *:S
- Note: log switch off, only log_main and log_events will have logs!
- --------- beginning of /dev/log/main
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
可以同时设置多个过滤器 : 使用adb logcat WifiHW:D dalvikvm:I *:S 命令, 输出 WifiHW 标签 的 Debug 以上级别 和 dalvikvm 标签的 Info 以上级别的日志;
- octopus@octopus:~$ adb logcat WifiHW:D dalvikvm:I *:S
- Note: log switch off, only log_main and log_events will have logs!
- --------- beginning of /dev/log/main
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- E/dalvikvm( 756): GC_CONCURRENT freed 1820K, 27% free 19490K/26695K, paused 17ms+2ms, total 110ms
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- E/dalvikvm( 756): GC_CONCURRENT freed 1810K, 27% free 19489K/26695K, paused 17ms+5ms, total 108ms
- E/WifiHW ( 441): wifi_send_command : AP_SCAN 1 ; interface index=0;
- E/WifiHW ( 441): wifi_send_command : SCAN_RESULTS ; interface index=0;
- Android---adb的常见命令操作
- adb 的常见命令操作
- android常见的 adb命令
- Android 常见的adb命令
- adb常见操作命令
- Android:adb 常见命令
- Android中常见的adb命令
- Android常见的adb命令大全
- android开发常见命令操作(需要配置adb.exe的环境变量)
- android:adb操作命令
- Android常见adb命令一
- Android应用程序的调试(之常见的adb命令)
- 比较常见的adb命令
- Android开发中常见adb命令的使用
- android adb命令操作程序
- android ADB基本操作命令
- 【Android】adb操作命令详解
- Android之adb操作命令
- C++三种(private,protected,public)继承方式的可见性说明
- 什么是CDN及CDN加速原理
- Cas4.2.7完整版部署文档
- MySQL基本概念
- 书籍-微服务架构与实践
- Android---adb的常见命令操作
- 查看医学影像文件软件
- ORACLE使用EXPDP和IMPDP数据泵进行导出导入的方法
- 什么是数据库实例
- QT下载地址
- (三) Spring Boot学习笔记之Spring Boot整合Logback
- 逻辑程序设计语言Prolog
- 关于haproxy和keepalived导致的日常问题总结汇总
- 文本域表单验证