Android 日常调试技巧

查看已连接的设备

adb devices

登录设备 shell

adb shell
adb shell -s your_device_id

安装应用

adb install your_apk_file
adb install -r your_apk_file

卸载应用

adb uninstall your_apk_name

在 shell 里启动应用

adb shell am start -n your.app.package/.MainActivity

执行一些操作

adb shell input keyevent keyevent_number

Telephony Log

adb logcat -b radio -v time
adb logcat -b system -b main -b radio -b events -v time
adb logcat -b system -b main -b radio -b events -v threadtime
adb logcat -v time -s pppd

AP Log

/* init.rc */
service logcat-debug /system/bin/logcat -b system -b main -b radio -b events -n 20 -r 4096 -v threadtime -f /data/logs/debug.log

IP Log

  1. 在 Termianl 1 里用 tcpdump 抓取 iplog
adb shell
adb root  
adb remount  
adb shell  
tcpdump -i any -s 0 -w /data/logs/iplog.pcap &  
  1. 在 Terminal 2 里把 IP Log 抓取到本地
mkdir ip_logs  
cd ip_logs  
adb pull /data/logs ./  
  1. 用 wireshark 进行分析
wireshark iplog.pcap  

过滤日志

adb logcat -s your_tag_name
adb logcat -s your_tag_name_1 your_tag_name_2
adb logcat "*:priority"
V — Verbose (lowest priority)
D — Debug
I — Info
W — Warning
E — Error
F — Fatal
S — Silent (highest priority, on which nothing is ever printed)
adb logcat -s your_tag_name:priority
adb logcat -s your_tag_name_1:priority your_tag_name_2:priority
adb logcat | grep "search_term"
adb logcat | grep "search_term_1\|search_term_2"

清除 logcat buffer

adb logcat -c

WiFi 无线调试

  1. 手机上的操作
su
setprop service.adb.tcp.port 5555
stop adbd
start adbd
  1. 电脑上的操作
adb connect 192.168.13.218:5555
adb shell

用 busybox 来 mount 文件夹

adb push busybox-armv7l /sdcard/busybox

adb shell
su
cd /sdcard/busybox
chmod 755 busybox

busybox mount -o remount,rw /system

扩展阅读

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容