我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用logcat吗?
我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用logcat吗?
当前回答
我找到了三种解法。
在Android 4.0设备上调试(我之前在Android Lollipop设备上运行它)。 单击DDMS中的重启按钮。 启动Android设备监视器,你会发现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.
禁用并卸载您最近安装且不使用的任何插件。
我尝试了上面的建议。然而,没有一个成功。然后我做了下面的事情,结果出乎意料地奏效了:
断开设备的USB接口 使用adb tcpip 5555和adb connect <device ip>命令通过Wi-Fi连接设备 使用adb kill-server断开设备与adb的连接 通过USB重新连接设备
然后LogCat显示日志。尽管在第2步时日志可用,但以下步骤在通过USB连接时为我解决了这个问题。
为我禁用验证应用程序通过USB和验证字节码 可调试的应用程序帮助我使logcat更加可靠。
好吧,我已经试过了所有其他的答案,没有一个对可怜的日志猫有效。 我对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)错误标记)。
我希望这对其他人有所帮助。