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

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


当前回答

在android Studio应用程序中,您需要单击调试应用程序选项(Shift+f9)以调试模式运行并启用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 1.4)。因此,尝试在TAG中放入任何字母(空格无效)。

Log.wtf("x", "Android Studio Team, solve this, please!");

需要连续两次按“Alt+6”重新启动logcat窗口。这样它就会显示日志输出。

问题主要发生在调试模式。

我尝试了上面的建议。然而,没有一个成功。然后我做了下面的事情,结果出乎意料地奏效了:

断开设备的USB接口 使用adb tcpip 5555和adb connect <device ip>命令通过Wi-Fi连接设备 使用adb kill-server断开设备与adb的连接 通过USB重新连接设备

然后LogCat显示日志。尽管在第2步时日志可用,但以下步骤在通过USB连接时为我解决了这个问题。

如果同时使用多个版本的adb, Logcat可能会失败。一个在Android Studio,一个在终端。

你可能有不同版本的adb: sudo apt-get install android-tools-adb将创建/usr/bin/adb Android SDK包含{Android - SDK}/platform-tools/adb, 或者从创建/host/linux-x86/bin/adb的AOSP构建的输出

要查看这个问题是否影响到你,使用“Help -> Show Log in Files”打开idea.log,并寻找类似于“Initializing adb using:/home/repkap11/android-sdk/platform-tools/adb”的行。将此路径与终端中的“which adb”进行比较。如果它们不匹配,这个问题就会影响到您。

Android studio寻找{Android -sdk}/platform-tools/adb,并不关心你的PATH。我用符号链接替换了android-sdk中的adb版本,但简单地“sudo apt-get remove android-tools-adb”也可以。