在真实手机(而不是模拟器)上使用 adb logcat
当我使用 Android 模拟器时,我可以执行“adb logcat”来查看源自我的代码的输出消息 (log / system.out.println)。它还显示执行期间发生的异常的堆栈跟踪。
但是,当我使用真正的手机时,“adb logcat”不会执行/显示任何内容。
我还尝试了“adb -d logcat”,它也没有显示任何内容。
有什么办法让它在真机上工作吗?
谢谢。
更新:
我刚刚尝试了“adb -s ? logcat”(“?”是设备的序列号),但也没有得到任何结果。
我尝试了另一个“adb”命令来查看是否有任何功能:“adb -s ? bugreport”。这打印了很多东西。示例:“内存信息”、“CPU 信息”和一些 Java 特定的内容。所以看起来有些东西正在发挥作用。
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.
But, when I'm using a real phone, "adb logcat" does not do / show anything.
I also tried "adb -d logcat" which also does not display anything.
Is there any way to get it working with the real phone?
Thanks.
UPDATE:
I just tried "adb -s ? logcat" ('?' is the serial number of the device) and also got no results.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
有同样的问题,但在 logcat 中添加了一个过滤器,只给他一个名称并将日志级别设置为“详细”。你可以尝试一下。
如果消息太长,我看不到某些异常的完整消息。滚动功能不太好。
(使用 Eclipse)
Jelmert
Had the same issue but added a filter in the logcat and only give him a name and set log level to "verbose". You can try that.
I can't see the complete message of some exceptions if the message are to long. Scrolling doesn't function very well.
(Using Eclipse)
Jelmert
在 Windows 命令/Linux shell 上,发出以下命令,
如果结果中未列出设备,则安装“APK 安装程序”,它可以帮助在 Windows 计算机中安装 adb 驱动程序。链接如下:
http://apkinstaller.com/downloads/
使用上面的命令再次检查列表shell/cmd,如果设备已列出,那么 Log Cat 肯定会工作。
之后您可以尝试:
查看 YouTube 上的教程:https://youtu.be/vO0Wf0E6Z4o
快乐编码: -)
On the windows command/Linux shell, issue the command below,
if the device is not listed in result, then install "APK installer", which can help install the adb driver in your windows machine. Link is below:
http://apkinstaller.com/downloads/
Check the listing again with the command above in the shell/cmd, and if the device is listed then Log Cat will surly work.
After that you can try:
Check the tutorial on YouTube: https://youtu.be/vO0Wf0E6Z4o
Happy Coding :-)
在华为U8185上启用logcat:
http://mjanja.co.ke/2012/ 08/在-huawei-u8185上启用-logcat/
Enabling logcat on the Huawei U8185:
http://mjanja.co.ke/2012/08/enabling-logcat-on-the-huawei-u8185/
在您的设备上启用 USB 调试。
将设备连接至计算机
使用以下命令:
获取“设备 id”
示例:
使用 logcat 时指定设备
示例:
Enable USB debugging on your device.
Connect the device to computer
Use these commands:
Get the "device id"
example:
To specify the device when using logcat
example:
不要忘记检查
设置 ->应用-> USB调试
。然后
将显示日志消息。
Don't forget to check
Settings -> Applications -> USB debugging
.Then
will show log messages.
获取设备列表:
adb devices
您将得到:
使用如下参数运行日志:
adb -s "0123456789ABCDEF" logcat MyTag:D *:S
其中“MyTag”是日志中使用的标签。 d("MyTag", value) 否则你会得到太多文本。
Get list of devices:
adb devices
You will get this:
Run log with parameters like this:
adb -s "0123456789ABCDEF" logcat MyTag:D *:S
where "MyTag" is tag used in Log.d("MyTag", value) or you will get too many text.
这是通过命令行使用 LogCat 的最佳方法:
This is the best way to use LogCat via command line:
你可以执行“adb -d logcat”。这应该有效。
you can do "adb -d logcat". This should work.
您是否为该设备安装了 ADB 驱动程序?
adb devices
返回什么?模拟器的名称如
emulator-5554
等。如果您的设备安装正确,您也应该看到它。该名称取决于您使用的制造商。如果您没有看到您的设备,则驱动程序安装不正确。在 Google 上搜索“adb install drivers”。这里有一个可能适合您的点击: http://forum.xda- Developers.com/showthread.php?t=502010
have you installed ADB drivers for the device?
What does
adb devices
return?Emulators are named like
emulator-5554
etc. If your device is properly installed you should see it too. The name depends on which manufacturer you are using.If you don't see your device, the drivers are not installed correctly. Do some searches for "adb install drivers" on Google. Here's a hit that might do it for you: http://forum.xda-developers.com/showthread.php?t=502010
尝试将 Catlog 下载到您的手机
Try downloading Catlog to your phone
您可能还需要在移动设备上激活日志记录。
对于我的华为设备,我需要输入电话号码:
##2846579##
进入服务菜单。从那里我可以激活日志记录。不确定您使用的是什么设备,但可能也有一些服务菜单。
完成后,重新启动并使用 adb -d logcat 重
试
基督教
You probably need to activate logging on your mobile device too.
In the case of my Huawei device, I need to enter the phone number:
##2846579##
to get into a service menu. From there I could activate logging. Not sure what device you are using, but probably there is some service menu there too.
Once done, reboot and try again with adb -d logcat
Cheers
Christian