使用 Logcat 和模拟器进行 Android 调试。是否可以?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2581837/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Debugging with Logcat and Emulator. Is it possible?
提问by aarona
This is pretty simple: I'm using NetBeans on Linux with Android emulator 1.6. I have Logcat on my android phone, but the process of getting the messages to somewhere readable isn't smooth at all.
这非常简单:我在 Linux 上使用 NetBeans 和 Android 模拟器 1.6。我的 android 手机上有 Logcat,但是将消息发送到某个可读位置的过程一点也不顺利。
Can someone tell me how to get Logcat running on the emulator? Is there anything I can do to see debug messages other then having to copy the apk to my phone and testing it?
有人能告诉我如何让 Logcat 在模拟器上运行吗?除了必须将 apk 复制到我的手机并进行测试之外,我还能做些什么来查看调试消息?
Thanks in advance!
提前致谢!
回答by fadden
You have a few options for viewing the debug log output, assuming you have the SDK installed and your command path set up correctly:
假设您安装了 SDK 并且正确设置了命令路径,您有几个选项可以查看调试日志输出:
Type
adb logcat
. The log output from the connected device or running emulator will appear. I usually preferadb logcat -v time
to see the time stamps.Type
ddms
. This launches the stand-alone version of DDMS. It has a logcat display at the bottom.Install the ADT extension for Eclipse, and open the logcat view. (Since you're using NetBeans I assume this isn't what you want to do, but I'm mentioning it for completeness.)
键入
adb logcat
。将出现连接设备或正在运行的模拟器的日志输出。我通常更喜欢adb logcat -v time
查看时间戳。键入
ddms
。这将启动 DDMS 的独立版本。它在底部有一个 logcat 显示。为 Eclipse 安装 ADT 扩展,并打开 logcat 视图。(由于您使用的是 NetBeans,我认为这不是您想要做的,但我提到它是为了完整性。)
In all cases, the interaction is the same whether you're using a physical device or software emulator, because the ADB daemon conceals the details. Whatever you're doing for the device is also expected to work for the emulator.
在所有情况下,无论您使用物理设备还是软件模拟器,交互都是相同的,因为 ADB 守护程序隐藏了细节。无论您为设备做什么,都应适用于模拟器。
If you have a device and emulator connected simultaneously, you can use adb -e logcat
for the emulator and adb -d logcat
for the device. From stand-alone DDMS or Eclipse, just pick the device or emulator from the pop-up menu.
如果您同时连接了设备和模拟器,则可以将其adb -e logcat
用于模拟器和adb -d logcat
设备。从独立的 DDMS 或 Eclipse,只需从弹出菜单中选择设备或模拟器。
回答by Rutger van Baren
If you have setup nbandroid you can find the adb logcat viewer in netbeans under: Window -> Output -> ADB Log
如果您设置了 nbandroid,您可以在 netbeans 下找到 adb logcat 查看器:窗口 -> 输出 -> ADB 日志
--edit Just followed up on the post above and started using C:\Program Files (x86)\Android\android-sdk-windows\tools\ddms which is alot better then the one in netbeans.
--edit 刚刚跟进上面的帖子并开始使用 C:\Program Files (x86)\Android\android-sdk-windows\tools\ddms 这比 netbeans 中的要好得多。
回答by Janusz
The SDK comes with a handy tool called ddms it should be in the tools folder of the SDK. At the moment an Emulator is running, or a mobile phone is connected to your machine it should show up in ddms and you can see all the log output in ddms.
SDK 附带一个名为 ddms 的方便工具,它应该位于 SDK 的工具文件夹中。此时模拟器正在运行,或者手机连接到您的机器,它应该显示在 ddms 中,您可以在 ddms 中看到所有日志输出。