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

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


当前回答

重新启动Android Studio帮助了我。

其他回答

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模拟器,你可以擦除数据,然后再次启动模拟器。只有这个对我有用

如果同时使用多个版本的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”也可以。

在终端中执行此命令。它将重新开始工作。

adb kill-server && adb start-server

Logcat的右边有一个小图标。您可以使用该图标打开和关闭logcat。我通常可以通过单击图标(可能几次)使logcat激活。