我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用logcat吗?
我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用logcat吗?
当前回答
如果同时使用多个版本的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”也可以。
其他回答
还要小心这个坏男孩(即使重新启动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!!
确保您已经在build variables上下文菜单中启用了构建变量以“调试”。(你可以在窗口的左下角找到它)。如果您之前已经为应用程序签署了apk,则此选项将被设置为发布模式。这将导致调试消息不显示在日志猫中。
确保您导入了正确的类
import android.util.Log;
执行->debug命令 如果你失去了与主机的连接,它会要求重新连接。单击yes。这样就行了。