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

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


当前回答

查看LogCat Sitteng 在我的情况下,我不检查每一件事,使我

我再次检查一切为我工作

其他回答

在Android studio 0.8.0中,您应该在运行应用程序之前通过Tools -> Android启用ADB集成。然后日志猫将正常工作。请注意,如果您在应用程序运行时禁用ADB集成,然后再次启用它,那么日志猫不会显示任何东西,除非您重新构建项目。

好吧,我已经试过了所有其他的答案,没有一个对可怜的日志猫有效。 我对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视图总是空的。

原因简单得令人恼火: logcat视图在那里,但它已被移动到0宽度的更新!

你在“ALT 6”选项卡,你看到两个选项卡“ADB日志”和“设备| logcat” Devices | logcat实际上意味着它由Devices和logcat组成,用垂直边界分隔。 垂直边界可以移动,在更新期间,它似乎已经移动到100%正确。

这将导致logcat被收集但不显示,将鼠标指针移动到工具窗口的右侧,并将logcat拖回视图。

这个解决方案不会帮助每个人,但我发现许多人与工作ADB连接仍然没有logcat输出,这些可能会受到同样的问题。

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

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行为,突出显示您调试和开发所需的行和语法。 从现在开始,您需要通过调试窗口访问它。