1

I'm running the command

logcat -d AndroidRuntime:E *:S

When ran from adb on my computer, it displays all the things it should. When I try to run it from an Android application with

Runtime.getRuntime().exec("logcat -d AndroidRuntime:E *:S");

and print the output, it won't display anything except the headers.

How can I fix this?

Nic Wilson
  • 150
  • 3
  • 10

1 Answers1

1

First, this has never been supported.

Second, if you are running on Android 4.1 and later, you will only get any log messages that your own app logs, not messages from other apps, as you can no longer hold the READ_LOGS permission in an ordinary SDK app.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • why not, btw ? isn't exec supposed to run things as if you had opened a shell ? or is the application user excluded from some commands ? – njzk2 Jan 07 '13 at 18:10
  • @njzk2: Quoting [Dianne Hackborn](https://groups.google.com/group/android-developers/msg/22205f37ad6cf602): "Keep in mind that access to the logs has never been part of the SDK, and is still not part of the SDK. If you are relying on it then, even after this change, you run the risk of breaking in the future. (And that is partly why this got lost for documentation, it is not part of the SDK, so there isn't really a place to document it, in fact documenting it would kind-of make it a part of the SDK which we don't want. :p) " – CommonsWare Jan 07 '13 at 18:16
  • So to make it work I need to make a kernel with it as a System App? – Nic Wilson Jan 07 '13 at 18:24
  • @NicWilson: If you install the app on the system partition of a rooted device, you can sucessfully use things protected by the `READ_LOGS` permission. Or, you can build a ROM mod that contains your app, where your app and the firmware are both signed with the same signing key. I presume that these will let you see all log messages using the technique in your question. – CommonsWare Jan 07 '13 at 18:26
  • Thank you very much CommonsWare. I will make it happen. :] – Nic Wilson Jan 07 '13 at 18:46