我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用logcat吗?
我昨天安装了Android Studio,我试着用LogCat查看日志。但是日志里什么都没有。我使用终端运行。/adb logcat,它工作。
有人能给我解释一下如何在Android Studio中使用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)错误标记)。
我希望这对其他人有所帮助。
其他回答
我刚把它修好了。在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.
在Android 3.6.1中,我必须:
升级到最新的Android Studio版本(4.x.x) 重启Logcat 重启应用程序 重启Android Studio 重新启动Android测试设备
查看LogCat Sitteng 在我的情况下,我不检查每一件事,使我
我再次检查一切为我工作
在我的例子中,它通过TCP连接断开,即使设备出现了。
调用
adb connect <device ip>
重启logcat OK。
修复一些不必要的更改的最佳方法是使缓存无效
转到FILE ->,单击“INVALIDATE CACHES/RESTART”,然后弹出一个对话框, 选择“无效缓存/重新启动”按钮。
Android studio将自动重新启动并重新构建索引。