问题
I have a bug that happens very randomly, so I rely on a LogCat
monitoring app I bought off the Play Store, to see the exceptions thrown on my device when it happens. Since using Jelly Bean, I'm seeing no logging. I've read that, with Jelly Bean, an app can only see the LogCat
output of itself.
So outside of rooting my device, is there any way to read the LogCat
output of my app on my phone directly? I know I can use Eclipse, but, like I said, it happens so randomly and I can't manually recreate it.
回答1:
So outside of rooting my device, is there any way to read the LogCat output of my app on my phone directly?
Not really. You can read discussions on aLogcat bugtracker about this issue:
After doing some reading and some testing, I've found three ways to make aLogcat work, all of which use root.
More detailed discussion about READ_LOGS permission is not granted to 3rd party applications in Jelly Bean (api 16)
回答2:
What do you think about writing directly to the screen using a textView? Of course this would only be for a debug build.
This post contains code that prints logcat errors on the screen Write android logcat data to a file
Now all that's left to do is to put try/catch stmts in your code, where the try surrounds code you think is problematic. The catch delegates to writing the error message to your screen.
来源:https://stackoverflow.com/questions/12407797/using-logcat-on-jellybean