How to get crash log from Android application
Because get crash log is not simple, for developers, it might not that hard, but for other people, it’s not easy, because we need enable…
Because get crash log is not simple, for developers, it might not that hard, but for other people, it’s not easy, because we need enable debug mode, and connect the device with computer, in order connect device with adb
, we also need to install platform-tools
.
So I am thinking of writing am application, which can get the crash log from the device, so anyone who want to get the crash log, just install the application, and use this application to get the crash log, and send it to the developers, so that the developer can analysis the reason of the crash.
I wrote an application to get the crash log with logcat
command, but the app can the crash log for that app only, and it can’t get the logs from other apps. I find there is a permission READ_LOGS
, but on its document, we can not get the logs for third-party app’s, the description is like below:
Allows an application to read the low-level system log files.
Not for use by third-party applications, because Log entries can contain the user’s private information.
Constant Value: “android.permission.READ_LOGS”
Because we only get crash logs for the self application, so It’s best to get the crash log on the application, and send the crash log to the server, so that the developer can get the crash log from server, and the tests don’t need install adb and learn how to get the crash log from comman line.
Demo project
I also wrote a demo project on the github:
The screenshot of the demo
In this demo, there are three buttons, the first one is refresh the crash log, the second one is clear the crash log, and the last one is make the app crash, so with the third button, we can demo crash a log, and when the app started, it will get the crash log.