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

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


当前回答

我刚把它修好了。在DDMS显示的最右边寻找恢复Devices Logcat视图和ADB视图的小图标。

When the DDMS first came up with both the "ADB Logs" and the "Devices | logcat" tab showing. The "Devices | logcat" is the one that should be showing the device output, but was blank. Somehow I managed to hide one or the other of those tabs, I forget exactly how. But, off to the right there was a tiny icon that said "Restore ADB" view, and I clicked it and it came up. Then there was another tiny icon that said "Restore Devices logcat view". I clicked that, and all of a sudden it appeared and was showing the device output again.

其他回答

步骤1:连接你的手机与Android开发者选项和USB调试。

步骤2:进入“查看>工具窗口> Logcat”

第三步:在运行项目之前,确保你的手机连接Android Studio。然后运行应用

注意:如果不能显示Logcat,请重新启动Android Studio: File > Invalid Caches/ Restart

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

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

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

重新启动logcat总是对我有帮助。

在android Studio应用程序中,您需要单击调试应用程序选项(Shift+f9)以调试模式运行并启用LogCat。

确保您导入了正确的类

import android.util.Log;