我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用logcat吗?
我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用logcat吗?
当前回答
今天也遇到了同样的问题。
显然,我也运行了eclipse,所有的logcat输出都被重定向到eclipse。由于日志只能在一个地方显示,请确保您没有运行多个调试器。
其他回答
好吧,我已经试过了所有其他的答案,没有一个对可怜的日志猫有效。 我对logcat的问题是,它从来没有工作开始。 当我安装Android studio并最终能够将设备连接到adb时,它从未给我输出。 这可能是由我的32位Windows 7设置造成的… 所以我写了一个批处理脚本,通过终端运行应用程序与logcat。
adb shell am start -n "com.package.name/com.package.name.Activity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
adb shell pidof com.package.name > pid
for /f %%i in (pid) do (set pid=%%i)
echo %pid%
adb logcat *:V --pid=%pid%
ENDLOCAL
将这些文件连同正确的目录路径和包名一起放入logcat.bat(或其他任何文件)文件中。
将文件放在AndroidStudioProjects/package_name/文件夹中,然后你就可以运行了
用户C: \ \我\ AndroidStudioProjects \ package_name > logcat(或其他)
在终点站。
注意,您可以通过更改更改logcat显示的内容
*: V
在adb logcat命令中。(示例*:E只显示(E)错误标记)。
我希望这对其他人有所帮助。
在我的情况下,我只是过滤了输出,所以即使在重新启动Logcat等后,它也显示为空。
这不是一个技术性的答案,但您可能想要检查logcat的搜索框。如果输入了任何字符,你的logcat将为空,因为它将搜索特定的字符或单词,然后如果它不存在,你的logcat日志将完全为空。
重新启动logcat总是对我有帮助。
我刚把它修好了。在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.