我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。

有人能给我解释一下如何在Android Studio中使用logcat吗?


当前回答

Easy fix that worked for me (after trying some of these other suggestion). My logcat was sitting blank in a separate window (on my second screen). Just had to drag the Logcat tab back to it's original place in the debug panel next to the Debugger and Console tabs, and VOILA... it began immediately updating and showing all processes verbose. So (If your logcat is anywhere outside of the debugger panel (i.e. the logcat tab isn't sitting nested alongside the debugger and console tab) then it won't receive updates and will sit there blankly. Don't know if this is an issue with older versions of Android Studio. But again, easy to try and if it works... it works!!

其他回答

在Android studio 0.8.0中,您应该在运行应用程序之前通过Tools -> Android启用ADB集成。然后日志猫将正常工作。请注意,如果您在应用程序运行时禁用ADB集成,然后再次启用它,那么日志猫不会显示任何东西,除非您重新构建项目。

我刚把它修好了。在DDMS显示的最右边寻找恢复Devices Logcat视图和ADB视图的小图标。

When the DDMS first came up with both the "ADB Logs" and the "Devices | logcat" tab showing. The "Devices | logcat" is the one that should be showing the device output, but was blank. Somehow I managed to hide one or the other of those tabs, I forget exactly how. But, off to the right there was a tiny icon that said "Restore ADB" view, and I clicked it and it came up. Then there was another tiny icon that said "Restore Devices logcat view". I clicked that, and all of a sudden it appeared and was showing the device output again.

这可能不是你的问题,但我发现当Android Studio打开多个窗口时,logcat只指向其中一个,而不一定是正在运行活动应用程序的那个。

例如,窗口1是我开发一字棋应用程序的地方,窗口2是我开发天气应用程序的地方。如果我在调试模式下运行天气应用程序,可能只有窗口1能够显示logcat条目。

步骤1:连接你的手机与Android开发者选项和USB调试。

步骤2:进入“查看>工具窗口> Logcat”

第三步:在运行项目之前,确保你的手机连接Android Studio。然后运行应用

注意:如果不能显示Logcat,请重新启动Android Studio: File > Invalid Caches/ Restart

一些自定义rom出于性能原因禁用日志记录(尽可能压缩%)检查rom的内置应用程序或调整rom的菜单来启用此功能。

我在我的i9505上运行贵山的Galaxy S4 Rom,我不知道它默认禁用了日志记录,以获得最分钟的性能提升,但显然这在定制的“性能”导向型Rom上并不罕见。我花了一段时间才发现这一点-非常烦人,因为它会显示我有多少消息被记录,而不是他们的细节。