Android 将 adb logcat 与真实手机(而不是模拟器)一起​​使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3707880/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 11:28:22  来源:igfitidea点击:

Using adb logcat with a real phone (and not the emulator)

androidadblogcat

提问by MyName

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.

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

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

但是,当我使用真正的手机时,“adb logcat”不会做/显示任何事情。

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

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

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.

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

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.

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

回答by AndreS

  1. Enable USB debugging in your device.

  2. Connect device to computer

  3. Use this commands

  1. 在您的设备中启用 USB 调试。

  2. 将设备连接到计算机

  3. 使用这个命令

--> $adb devices (will give the "device id" that is connected) output ex. 82990AB830201D device

--> $adb devices(将给出连接的“设备ID”)输出例如。82990AB830201D 装置

--> $adb -s "device id" logcat (you will be able to see your device logcat)

--> $adb -s "device id" logcat (你将能够看到你的设备 logcat)

ex $adb -s 82990AB830201D logcat

前 $adb -s 82990AB830201D logcat

I follow this steps and it works good.

我按照此步骤操作,效果很好。

回答by Diego Torres Milano

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

不要忘记检查Settings -> Applications -> USB debugging。然后

 $ adb -d logcat

will show log messages.

将显示日志消息。

回答by Deleted because of negativity

  1. Get list of devices:

    adb devices

  1. 获取设备列表:

    亚行设备

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

  1. 使用如下参数运行日志:

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

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

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

回答by MrG

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

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

adb logcat -v time > log.txt

回答by Sephy

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

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

回答by John

Try downloading Catlogto your phone

尝试将Catlog下载到您的手机

回答by Juan Ignacio Barisich

  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
  1. 在您的设备中启用 USB 调试。
  2. 将您的设备连接到计算机
  3. 打开安卓工作室
  4. 单击查看/工具 Windows/Logcat(或 Alt+6)
  5. 在左上角的组合框中选择您的设备

enter image description here

在此处输入图片说明

回答by Abhinav Saxena

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

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

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:

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

http://apkinstaller.com/downloads/

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.

在 shell/cmd 中使用上面的命令再次检查列表,如果设备被列出,那么 Log Cat 将正常工作。

After that you can try:

之后你可以尝试:

adb -d logcat

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

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

Happy Coding :-)

快乐编码:-)

回答by Christian

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##

在我的华为设备的情况下,我需要输入手机号码: #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

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

Cheers Christian

干杯基督徒

回答by Key

have you installed ADB drivers for the device?

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

What does adb devicesreturn?

什么adb devices回报?

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

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

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

如果您没有看到您的设备,则说明驱动程序安装不正确。在 Google 上搜索“adb install drivers”。这是一个可能为你做的热门:http: //forum.xda-developers.com/showthread.php?t=502010