Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
408 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...