Android 在 Logcat 上启用来自真实设备的日志消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3060982/
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
Enable Log messages from real device on Logcat
提问by poeschlorn
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.
对于我的 android 应用程序开发,我试图从我的真实设备(当从 eclipse 启动应用程序时)而不只是从我的模拟器获取 logcat 消息。
Does someone know how to enable such a feature?
有人知道如何启用这样的功能吗?
回答by James
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.
您需要在您的设备上启用 USB 调试。转到设置、应用程序、开发并勾选“USB 调试”。然后当您的设备通过 USB 连接时,您可以在 DDMS 中看到它的名称,就好像它是另一个模拟器一样。
回答by Pentium10
It works like the emulator, use the ddms or eclipse plugin to get the logcat from your app running on devices.
它像模拟器一样工作,使用 ddms 或 eclipse 插件从设备上运行的应用程序中获取 logcat。
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.
否则,您始终可以选择使用Log Collector
应用程序(从 Market 下载免费应用程序),如果他们想向您发送日志,您可以告诉您的用户使用此类应用程序。
回答by adamk
Sometimes, you have to explicitly enable debugging on a real device.
有时,您必须在真实设备上显式启用调试。
- It could be that a device android image is built with debuggable property as off (you can check that by running
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). - Some devices (e.g. Motorola Cliq) disable by default all verbose and debug log messages.
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 映像是使用 debuggable 属性构建的(您可以通过运行来检查
adb shell getprop
)。在这种情况下,您需要在 AndroidManifest.xml (<application .... android:debuggable="true">
)中将您的应用程序声明为可调试的。这实际上在此处的 Android 开发指南中明确说明(在设置您的设备进行开发下,其中还提到打开“USB 调试”和一些其他调整)。 - 某些设备(例如 Motorola Cliq)默认禁用所有详细和调试日志消息。要使其工作,您必须
adb shell setprop log.debug_level 1
在设备上运行,然后调试消息才起作用(即,直到您重新启动设备)。
回答by user3400880
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
我认为您应该先为您的 android 设备安装一个合适的 USB 驱动程序,然后您的 eclipse 会将您的设备识别为 android 设备并开始调试