我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用logcat吗?
我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用logcat吗?
当前回答
重新启动Android Studio帮助了我。
其他回答
Logcat的右边有一个小图标。您可以使用该图标打开和关闭logcat。我通常可以通过单击图标(可能几次)使logcat激活。
奇怪的是,即使是在最近版本的Android Studio上,仍然会遇到这个问题。我通读了一长串的解决方案,但它们对我不起作用。 接受的答案适用于早期版本的Android Studio(我猜是v2.3)
我做了以下让Logcat再次工作:
Logcat >只显示选中的应用>不显示过滤器
Logcat >不过滤>只显示选中的应用
我期望重置logcat应该理想地给我同样的效果,但它没有。手动切换滤镜是唯一有效的方法。
这是在Android Studio 3.0.1(稳定)(我不能在完成当前项目之前更新它) 问题发生在我早上启动Android工作室继续我晚上留下的工作时。我希望开发人员能研究一下这个问题。从stackoverflow中尝试了超过15个解决方案,仍然没有看到任何结果。为这个问题的未来受害者揭示另一种解决方案甚至令人恼火。
除了所有好的答案之外:如果您使用BuildConfig,请确保您导入了正确的BuildConfig。我正在使用BuildConfig。所以有一天我的IDE自动导入了错误的类
import com.google.firebase.BuildConfig;
也可能是
import com.adjust.sdk.BuildConfig;
将import更改为正确的导入后,一切正常:
import com.yourapp.BuildConfig;
所有这些都无济于事,我的日志猫功能失常。
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行为,突出显示您调试和开发所需的行和语法。 从现在开始,您需要通过调试窗口访问它。
修复一些不必要的更改的最佳方法是使缓存无效
转到FILE ->,单击“INVALIDATE CACHES/RESTART”,然后弹出一个对话框, 选择“无效缓存/重新启动”按钮。
Android studio将自动重新启动并重新构建索引。