如何在 Eclipse 中查看 Android 的错误日志 (logcat)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2866565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:39:42  来源:igfitidea点击:

How can I see the error log (logcat) for Android in Eclipse?

androideclipseerror-log

提问by jul

How / where can I see what happened when my Android application crashes in Eclipse (using Run, not Debug)?

当我的 Android 应用程序在 Eclipse 中崩溃(使用运行,而不是调试)时,我如何/在哪里可以看到发生了什么?

回答by aioobe

Window → Show View → Other, then select Android / LogCat

Window → Show View → Other,然后选择Android / LogCat



enter image description hereenter image description here



enter image description hereenter image description here

(If you already see the view, but it doesn't seem to show the correct / up-to-date output, try reselecting the desired device in the devices view.)

(如果您已经看到该视图,但它似乎没有显示正确/最新的输出,请尝试在设备视图中重新选择所需的设备。)

回答by Edward Falk

Sometimes the device gets "out of sync" with eclipse and logcat doesn't show any messages, as you've discovered.

正如您所发现的,有时设备会与 eclipse“不同步”并且 logcat 不显示任何消息。

To fix this, try a) going to DDMS and selecting your device; b) closing the logcat tab and creating a new one; c) disconnecting your device and reconnecting it; d) exiting eclipse and restarting it; e) rebooting your device; or f) rebooting your computer, in that order. Usually the problem is fixed by the time you've done a).

要解决此问题,请尝试 a) 转到 DDMS 并选择您的设备;b) 关闭 logcat 选项卡并创建一个新选项卡;c) 断开您的设备并重新连接;d) 退出 eclipse 并重新启动它;e) 重新启动您的设备;或 f) 按此顺序重新启动计算机。通常问题在您完成 a) 时就已解决。

回答by Mathias Conradt

I found Eclipse not very reliable and switched to IntelliJ, much happier that way. IntelliJ 9 supports Android development (not the community edition though). Beside Eclipse DDMS, you can also see the logcat from the command line. Open a shell and change to the folder of your Android SDK, and here to subfolder 'tools'. There you can run

我发现 Eclipse 不是很可靠,于是切换到 IntelliJ,这样更开心。IntelliJ 9 支持 Android 开发(虽然不是社区版)。除了 Eclipse DDMS,您还可以从命令行查看 logcat。打开一个 shell 并切换到您的 Android SDK 的文件夹,并在此处切换到子文件夹“tools”。在那里你可以跑

adb shell logcat

which will show you the log.

这将显示日志。

If you want to explicit distinguish between real device or emulator (in case you're using both), you can add parameters -d or -e

如果你想明确区分真实设备或模拟器(如果你同时使用两者),你可以添加参数 -d 或 -e

Device:

设备:

adb -d logcat

Emulator:

模拟器:

adb -e logcat