在真实手机(而不是模拟器)上使用 adb logcat

发布于 2024-09-19 19:27:28 字数 426 浏览 14 评论 0原文

当我使用 Android 模拟器时,我可以执行“adb logcat”来查看源自我的代码的输出消息 (log / system.out.println)。它还显示执行期间发生的异常的堆栈跟踪。

但是,当我使用真正的手机时,“adb logcat”不会执行/显示任何内容。

我还尝试了“adb -d logcat”,它也没有显示任何内容。

有什么办法让它在真机上工作吗?

谢谢。

更新:

我刚刚尝试了“adb -s ? logcat”(“?”是设备的序列号),但也没有得到任何结果。

我尝试了另一个“adb”命令来查看是否有任何功能:“adb -s ? bugreport”。这打印了很多东西。示例:“内存信息”、“CPU 信息”和一些 Java 特定的内容。所以看起来有些东西正在发挥作用。

when I'm using the Android emulator I can do "adb logcat" to see output messages (log / system.out.println) originated from my code. It also shows the stack trace of exceptions which happen during execution.

But, when I'm using a real phone, "adb logcat" does not do / show anything.

I also tried "adb -d logcat" which also does not display anything.

Is there any way to get it working with the real phone?

Thanks.

UPDATE:

I just tried "adb -s ? logcat" ('?' is the serial number of the device) and also got no results.

I tried another "adb" command to see if anything was working: "adb -s ? bugreport". This printed a lot of stuff. Example: "Memory Info", "CPU Info" and some Java specific things. So it seams that some stuff is working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

清浅ˋ旧时光 2024-09-26 19:27:29

有同样的问题,但在 logcat 中添加了一个过滤器,只给他一个名称并将日志级别设置为“详细”。你可以尝试一下。

如果消息太长,我看不到某些异常的完整消息。滚动功能不太好。

(使用 Eclipse)

Jelmert

Had the same issue but added a filter in the logcat and only give him a name and set log level to "verbose". You can try that.

I can't see the complete message of some exceptions if the message are to long. Scrolling doesn't function very well.

(Using Eclipse)

Jelmert

江湖彼岸 2024-09-26 19:27:29

在 Windows 命令/Linux shell 上,发出以下命令,

adb devices 

如果结果中未列出设备,则安装“APK 安装程序”,它可以帮助在 Windows 计算机中安装 adb 驱动程序。链接如下:

http://apkinstaller.com/downloads/

使用上面的命令再次检查列表shell/cmd,如果设备已列出,那么 Log Cat 肯定会工作。

之后您可以尝试:

adb -d logcat

查看 YouTube 上的教程:https://youtu.be/vO0Wf0E6Z4o

快乐编码: -)

On the windows command/Linux shell, issue the command below,

adb devices 

if the device is not listed in result, then install "APK installer", which can help install the adb driver in your windows machine. Link is below:

http://apkinstaller.com/downloads/

Check the listing again with the command above in the shell/cmd, and if the device is listed then Log Cat will surly work.

After that you can try:

adb -d logcat

Check the tutorial on YouTube: https://youtu.be/vO0Wf0E6Z4o

Happy Coding :-)

愁杀 2024-09-26 19:27:28
  1. 在您的设备上启用 USB 调试

  2. 将设备连接至计算机

  3. 使用以下命令:

获取“设备 id”

adb devices

示例:

$ adb devices
List of devices attached
5856423841563398    device
emulator-5554   device

使用 logcat 时指定设备

adb -s "device id" logcat

示例:

$ adb -s 5856423841563398 logcat
--------- beginning of crash
03-31 15:56:51.174 13547 13547 E AndroidRuntime: FATAL EXCEPTION: main
  1. Enable USB debugging on your device.

  2. Connect the device to computer

  3. Use these commands:

Get the "device id"

adb devices

example:

$ adb devices
List of devices attached
5856423841563398    device
emulator-5554   device

To specify the device when using logcat

adb -s "device id" logcat

example:

$ adb -s 5856423841563398 logcat
--------- beginning of crash
03-31 15:56:51.174 13547 13547 E AndroidRuntime: FATAL EXCEPTION: main
幻梦 2024-09-26 19:27:28

不要忘记检查设置 ->应用-> USB调试
然后

 $ adb -d logcat

将显示日志消息。

Don't forget to check Settings -> Applications -> USB debugging.
Then

 $ adb -d logcat

will show log messages.

柠檬 2024-09-26 19:27:28
  1. 获取设备列表:

    adb devices

您将得到:

List of devices attached
emulator-5554   device
0123456789ABCDEF        device
  1. 使用如下参数运行日志:

    adb -s "0123456789ABCDEF" logcat MyTag:D *:S

其中“MyTag”是日志中使用的标签。 d("MyTag", value) 否则你会得到太多文本。

  1. Get list of devices:

    adb devices

You will get this:

List of devices attached
emulator-5554   device
0123456789ABCDEF        device
  1. Run log with parameters like this:

    adb -s "0123456789ABCDEF" logcat MyTag:D *:S

where "MyTag" is tag used in Log.d("MyTag", value) or you will get too many text.

红墙和绿瓦 2024-09-26 19:27:28

这是通过命令行使用 LogCat 的最佳方法:

adb logcat -v time > log.txt

This is the best way to use LogCat via command line:

adb logcat -v time > log.txt
你怎么这么可爱啊 2024-09-26 19:27:28

你可以执行“adb -d logcat”。这应该有效。

you can do "adb -d logcat". This should work.

花开雨落又逢春i 2024-09-26 19:27:28
  1. 在您的设备中启用 USB 调试。
  2. 将您的设备连接到计算机
  3. 打开 Android Studio
  4. 单击“View/Tool Windows/Logcat”(或 Alt+6)
  5. 在左上角组合框中选择您的设备

在此处输入图像描述

  1. Enable USB debugging in your device.
  2. Connect your device to computer
  3. Open Android Studio
  4. Click on View/Tool Windows/Logcat (or Alt+6)
  5. Select your device on the top left combo box

enter image description here

和影子一齐双人舞 2024-09-26 19:27:28

您是否为该设备安装了 ADB 驱动程序?

adb devices 返回什么?

模拟器的名称如 emulator-5554 等。如果您的设备安装正确,您也应该看到它。该名称取决于您使用的制造商。

如果您没有看到您的设备,则驱动程序安装不正确。在 Google 上搜索“adb install drivers”。这里有一个可能适合您的点击: http://forum.xda- Developers.com/showthread.php?t=502010

have you installed ADB drivers for the device?

What does adb devices return?

Emulators are named like emulator-5554 etc. If your device is properly installed you should see it too. The name depends on which manufacturer you are using.

If you don't see your device, the drivers are not installed correctly. Do some searches for "adb install drivers" on Google. Here's a hit that might do it for you: http://forum.xda-developers.com/showthread.php?t=502010

故人爱我别走 2024-09-26 19:27:28

尝试将 Catlog 下载到您的手机

Try downloading Catlog to your phone

秋意浓 2024-09-26 19:27:28

您可能还需要在移动设备上激活日志记录。

对于我的华为设备,我需要输入电话号码:
##2846579##

进入服务菜单。从那里我可以激活日志记录。不确定您使用的是什么设备,但可能也有一些服务菜单。

完成后,重新启动并使用 adb -d logcat 重


基督教

You probably need to activate logging on your mobile device too.

In the case of my Huawei device, I need to enter the phone number:
##2846579##

to get into a service menu. From there I could activate logging. Not sure what device you are using, but probably there is some service menu there too.

Once done, reboot and try again with adb -d logcat

Cheers
Christian

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文