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

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


当前回答

在我的例子中,我从右边的小下拉列表中删除了“image”。在那之后一切都很好。这是因为它将在日志中搜索搜索框中的关键字,因此如果没有找到任何匹配项,它将返回空白

其他回答

在我的情况下,我只是过滤了输出,所以即使在重新启动Logcat等后,它也显示为空。

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

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

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

好吧,我已经试过了所有其他的答案,没有一个对可怜的日志猫有效。 我对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)错误标记)。

我希望这对其他人有所帮助。

所有这些都无济于事,我的日志猫功能失常。

After a lot of angry searching I found a solution that seems to work: 1. Make sure logcat itself is working (use DDMS from Tools->Android) and if it does close DDMS window again 2. Now go to Tab 5 (Debug), there select Logcat (this is not the same logcat as in Window 6!) 3. The window is empty just like Window 6, but now start a debugging run. For me logcat in the Debug window now started to show all the stuff again! Also when normally running the application the Debug->logcat view is still functional while the Tool Window #6 "logcat" is disfunctional as before

这是一个黑客,但是它会导致正常的logcat行为,突出显示您调试和开发所需的行和语法。 从现在开始,您需要通过调试窗口访问它。

还要小心这个坏男孩(即使重新启动android studio也没有消失):