在 Logcat 上启用来自真实设备的日志消息
对于我的 Android 应用程序开发,我试图从我的真实设备获取 logcat 消息(当从 eclipse 启动应用程序时),而不仅仅是从我的模拟器获取 logcat 消息。
有人知道如何启用这样的功能吗?
For my android app development, I am trying to get logcat messages from my real device (when starting an app on it from eclipse) and not just from my emulator.
Does someone know how to enable such a feature?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要在设备上启用 USB 调试。进入设置、应用程序、开发并勾选“USB 调试”。然后,当您的设备通过 USB 连接时,您可以在 DDMS 中看到它的名称,就像它是另一个模拟器一样。
You need to enable USB Debugging on your device. Go to settings, applications, development and tick "USB Debugging". Then when your device is connected by USB you can see its name in DDMS as if it was another emulator.
它的工作原理类似于模拟器,使用 ddms 或 eclipse 插件从设备上运行的应用程序获取 logcat。
否则,您始终可以选择使用
Log Collector
应用程序(从市场下载免费的应用程序),如果用户想向您发送日志,您可以告诉他们使用此类应用程序。It works like the emulator, use the ddms or eclipse plugin to get the logcat from your app running on devices.
Otherwise you have always the options to use a
Log Collector
app (download a free one from Market), you can tell your users to use such app if they want to send you the log.有时,您必须在真实设备上显式启用调试。
adb shell getprop
进行检查)。在这种情况下,您需要在 AndroidManifest.xml 中将您的应用程序声明为可调试 (
)。这实际上在 Android 开发指南 此处 中明确说明(在设置您的设备进行开发,其中还提到打开“USB 调试”和一些其他调整)。
要使其正常工作,您必须在设备上运行
adb shell setprop log.debug_level 1
,然后调试消息才会起作用(即,直到您重新启动设备为止)。Sometimes, you have to explicitly enable debugging on a real device.
adb shell getprop
).In this case you need to declare your app as debuggable in the AndroidManifest.xml (
<application .... android:debuggable="true">
).This is actually explicitly stated in the Android Dev Guide here (Under Set up your device for development, which also mentions turning on "USB Debugging" and a couple more tweaks).
For it to work, you must run
adb shell setprop log.debug_level 1
on the device and only then debug messages work (that is, until you power-cycle the device).我认为你应该首先为你的 Android 设备安装一个合适的 USB 驱动程序,然后你的 Eclipse 会将你的设备识别为 Android 设备并开始调试
I think you should install first a suitable usb driver for your android device then your eclipse will recognize your device as an android device and start debugging