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

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


当前回答

除了所有好的答案之外:如果您使用BuildConfig,请确保您导入了正确的BuildConfig。我正在使用BuildConfig。所以有一天我的IDE自动导入了错误的类

import com.google.firebase.BuildConfig;

也可能是

import com.adjust.sdk.BuildConfig;

将import更改为正确的导入后,一切正常:

import com.yourapp.BuildConfig;

其他回答

要运行Logcat,请重新启动Logcat,然后打开DDMS(要打开它,请单击Android DDMS右上角的Android图标)。设置“日志级别=调试”。然后运行你的应用。

全核解决方案。只有在尝试了所有其他方法后才使用这个方法,因为这将删除您所有的设置和首选项,以及存储的图像和所有使您的模拟器运行的东西,直到您重新安装和重新配置。以我为例,这两个步骤都花了大约20分钟,因为除了使用Darcula外,我没有进行太多自定义。

删除你的。androidstudiobeta配置文件目录

对于linux用户,这可以在/home/[username]/下找到。AndroidStudioBeta 对于windows用户,我不确定。在我看来,关于它的文件相当模糊。可能在C:\Users[你的用户]\Application Data下面

检查它是否工作,如果不能,然后重新安装SDK。

相当激烈,但我尝试了这个页面上的所有其他东西,连接设备,没有过滤器,重新启动服务,这个页面上的所有东西,它就是不工作。

在Android Studio 0.8.9中,我打开Android设备监视器,从设备列表中选择模拟器,并在LogCat选项卡中获得输出。

之后,我回到Android Studio的主视图,在Android DDMS选项卡的右侧选择Restore Logcat视图,它就在那里!

如果这不起作用,你可以在Android设备监视器中看到你的日志猫,就像我在第一句话中解释的那样。

这些帮助了我:

1.启用ADB集成 2. 进入Android设备监视器 检查您的设备是否在线,并创建所需的过滤器

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

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