如何在 Eclipse 中查看 Android 的错误日志 (logcat)?
当我的 Android 应用程序在 Eclipse 中崩溃时(使用“运行”,而不是“调试”),如何/在哪里可以看到发生了什么?
How / where can I see what happened when my Android application crashes in Eclipse (using Run, not Debug)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
窗口 → 显示视图 → 其他,然后选择 Android / LogCat
(如果您已经看到该视图,但它似乎没有显示正确/最新的内容) -date 输出,尝试在设备视图中重新选择所需的设备。)
Window → Show View → Other, then select Android / LogCat
(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.)
有时,设备与 eclipse “不同步”,并且 logcat 不会显示任何消息,正如您所发现的。
要解决此问题,请尝试 a) 转至 DDMS 并选择您的设备; b) 关闭 logcat 选项卡并创建一个新选项卡; c) 断开您的设备并重新连接; d) 退出 Eclipse 并重新启动它; e) 重新启动您的设备;或 f) 按顺序重新启动计算机。通常,当您完成 a) 后,问题就已得到解决。
Sometimes the device gets "out of sync" with eclipse and logcat doesn't show any messages, as you've discovered.
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).
我发现 Eclipse 不太可靠,于是改用 IntelliJ,这样更开心。 IntelliJ 9 支持 Android 开发(尽管不是社区版)。
除了 Eclipse DDMS 之外,您还可以从命令行查看 logcat。打开 shell 并更改为 Android SDK 的文件夹,此处为子文件夹“tools”。您可以在那里运行
,它将显示日志。
如果您想明确区分真实设备或模拟器(如果您同时使用两者),您可以添加参数 -d 或 -e
Device:
Emulator:
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
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
Device:
Emulator: