使用ADB查看安卓调试日志

使用ADB查看安卓调试日志

安装ADB工具

官网下载地址:http://adbdownload.com/

根据自己的操作系统选择下载对应的安装包,本文以Windows为例

连接安卓设备

将设备(如手机/平板)的USB调试打开, 不同设备和不同版本的开启方式不同,根据实际情况处理.

USB调试打开之后, 将设备(如手机/平板)等通过数据线连接到电脑上, 然后打开cmd工具,执行以下命令

PS D:\Software\AndroidKiller_v1.3.1\bin\adb> .\adb.exe devices
List of devices attached

稍等几秒钟, 安卓设备将弹出提示:"是否允许USB调试", 点击允许即可

再次执行devices​命令, 就可以从列表中看到设备了

PS D:\Software\AndroidKiller_v1.3.1\bin\adb> .\adb.exe devices
List of devices attached
88Y5T19A17001949        device

查看设备日志

通过adb -s [device] logcat​命令, 可以看到设备的系统日志信息

PS D:\Software\AndroidKiller_v1.3.1\bin\adb> .\adb.exe -s 88Y5T19A17001949 logcat
--------- beginning of crash
05-27 20:48:46.431   434   434 F libc    : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x14 in tid 434 (init), pid 434 (init)
05-27 20:48:46.432   573   573 F libc    : failed to exec crash_dump helper: No such file or directory
05-27 20:48:46.432   434   434 F libc    : crash_dump helper failed to exec, or was killed

可以直接进入设备, 再执行logcat​命令.

PS D:\Software\AndroidKiller_v1.3.1\bin\adb> .\adb.exe -s 88Y5T19A17001949 shell
HWTAS:/ $ logcat | grep conn
logcat | grep conn
06-07 13:53:54.220  2544  3032 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.bindService:2040 android.content.ContextWrapper.bindService:810 ohos.abilityshell.support.O00000O.O000000:770 ohos.abilityshell.support.O00000O.connectAbility:604 ohos.abilityshell.support.O00000o.O000000:164
06-07 13:53:57.451 13492 13504 I HwActivityThreadImpl: before connect app.socketName:bee8ebf6-0074-4256-b4ae-22e957e46792
06-07 13:53:57.464 13492 13504 I HwActivityThreadImpl: connectContinuePreload end mPreloadStatus 3
06-07 13:53:57.614 13492 13594 D BufferPoolManager: # of cleaned connections: 0

直接进入设备shell后再使用logcat​的好处是, windows不支持的常见linux命令, 在shell里面可以执行, 例如grep

更多logcat的用法,参考 https://www.jianshu.com/p/5eed217327f5

查看指定的APP

首先, 获取到App的进行,再通过logcat​的--pid​选项来查看指定的进程日志

D:\Software\AndroidKiller_v1.3.1\bin\adb>adb -s 88Y5T19A17001949 shell
#列举出设备的全部包列表
HWTAS:/ $ pm list packages 
pm list packages
package:com.huawei.security.hsdr
package:com.android.cts.priv.ctsshim

#筛选出App的完整包名
HWTAS:/ $ pm list packages | grep mobileqq
pm list packages | grep mobileqq
package:com.tencent.mobileqq

#通过包名获取App的进程ID
HWTAS:/ $ pidof -s com.tencent.mobileqq
pidof -s com.tencent.mobileqq
9897

#查看指定进程的日志信息
HWTAS:/ $ logcat --pid=9897
logcat --pid=9897
--------- beginning of main
06-13 11:53:55.805  9897  9986 I tg_ad_mob: reportDp3 miss rate
06-13 11:53:55.810  9897  9986 I tg_ad_mob: Update success
06-13 11:53:55.810  9897  9986 I tg_ad_mob: GdtConfigListener onADEvent GDT_CONFIG_UPDATE_DONE

如果在已知包名的情况下, 可以直接通过以下命令来查看对应包的日志信息

HWTAS:/ $ logcat --pid=$(pidof -s com.tencent.mobileqq)
logcat --pid=$(pidof -s com.tencent.mobileqq)
--------- beginning of main
06-13 11:56:59.001  9897 10328 I NTKernel: [I] gpro_polling_state_mgr.cpp(377)::PollingFromServer polling paused in background
06-13 11:57:00.294  9897 11157 I SmartThreadExecutor: handleMessage: start check 0
06-13 11:57:00.294  9897 11157 I SmartThreadExecutor: handleMessage: check end 0 -8 false
posted @   笨鸡蛋9毛  阅读(128)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
点击右上角即可分享
微信分享提示