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

有人能给我解释一下如何在Android Studio中使用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行为,突出显示您调试和开发所需的行和语法。 从现在开始,您需要通过调试窗口访问它。

其他回答

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

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

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

我检查了答案,只是在检查我的日志时偶然发现我的错误。 确保右边的方框显示“只显示选定的应用程序”。我的显示的是“Firebase”,所以它显示了来自Firebase的消息。

对我来说,问题在于设备是在“仅充电”模式下连接的。

将模式更改为媒体设备(MTP)(或在某些设备中传输文件)解决了问题。

Windows用户:

使用脚本工具。确保您已经为系统设置了ADB环境。 Android Logcat脚本

保存到bat文件 编辑文件。用包id替换com.example.abc 双击打开文件或通过MobaXTerm打开(方便查找文本)

p/s:如果这个答案有帮助,让我们把我的回购星。谢谢!

检查log标记中是否有空格。如果标签由空格组成,则删除空格,然后运行。您将能够查看日志。