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.
Solution 1:
-
Enable USB debugging on your device.
-
Connect the device to computer
-
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
Solution 2:
Don't forget to check Settings -> Applications -> USB debugging
.
Then
$ adb -d logcat
will show log messages.
Solution 3:
-
Get list of devices:
adb devices
You will get this:
List of devices attached
emulator-5554 device
0123456789ABCDEF device
-
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.
Solution 4:
This is the best way to use LogCat via command line:
adb logcat -v time > log.txt