将 adb logcat 与真实手机(而不是模拟器)一起使用 [英] Using adb logcat with a real phone (and not the emulator)
问题描述
当我使用 Android 模拟器时,我可以执行adb logcat"来查看源自我的代码的输出消息 (log/system.out.println).它还显示了在执行过程中发生的异常的堆栈跟踪.
when I'm using the Android emulator I can do "adb logcat" to see output messages (log / system.out.println) originated from my code. It also shows the stack trace of exceptions which happen during execution.
但是,当我使用真正的手机时,adb logcat"不执行/不显示任何内容.
But, when I'm using a real phone, "adb logcat" does not do / show anything.
我也试过adb -d logcat",它也没有显示任何内容.
I also tried "adb -d logcat" which also does not display anything.
有什么办法让它在真机上运行吗?
Is there any way to get it working with the real phone?
谢谢.
更新:
我刚刚尝试了adb -s ? logcat"('?' 是设备的序列号),也没有结果.
I just tried "adb -s ? logcat" ('?' is the serial number of the device) and also got no results.
我尝试了另一个adb"命令来查看是否有任何工作:adb -s ? bugreport".这打印了很多东西.示例:内存信息"、CPU 信息"和一些 Java 特定的东西.所以看起来有些东西正在起作用.
I tried another "adb" command to see if anything was working: "adb -s ? bugreport". This printed a lot of stuff. Example: "Memory Info", "CPU Info" and some Java specific things. So it seams that some stuff is working.
推荐答案
在您的设备上启用 USB 调试.
Enable USB debugging on your device.
将设备连接到计算机
使用这些命令:
获取设备 ID"
adb devices
示例:
$ adb devices
List of devices attached
5856423841563398 device
emulator-5554 device
使用logcat时指定设备
To specify the device when using logcat
adb -s "device id" logcat
示例:
$ adb -s 5856423841563398 logcat
--------- beginning of crash
03-31 15:56:51.174 13547 13547 E AndroidRuntime: FATAL EXCEPTION: main
这篇关于将 adb logcat 与真实手机(而不是模拟器)一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!