In this post, I will be discussing about the Android BugReport. What it is and how we can analyze it in a much easier way.
Many a times, Android developers have been given a bugreport to analyze some critical or rarely occurring issues in Android. And literally, they have no clue, on what the scenarios the customer has faced the issue. They only have to figure it out by investigating the bugreport. So, what exactly this bugReport is? and what it contains? Let’s find out.
What is Android Bugreport?
A bugreport is a plain text file that contains lots of information such as device logs, stack traces, ANR, kernel logs, dumpsys, memory info, etc.
How to Capture BugReport?
There are many ways to capture bug report.
Capture from device
- Enable Developer Option
- Open Developer Option and Tap on “Take bug report“.
- Select the type of bugreport you want and tap Report. (After few seconds, you will get a notification saying BugReport is captured.)
- If you want to share that bugReport, tap on that notification and share it.
Capture from ADB
If you have only one device connected, use the below command.
$ adb bugreport E:\Reports\MyBugReports
If more than one device is connected, use the -s option to selet the device.
$ adb devices List of devices attached emulator-5554 device 8XV7N15C31003476 device $ adb -s 8XV7N15C31003476 bugreport
Analyzing Android BugReport Made easy with CheckBugReport
No doubt that BugReport provides a large set of information that a programmer ever needs, but how feasible it to read? Many programmers find it difficult to analyze the RAW bugReport generated by device. Its like every bit of information have been dumped into a text garbage and programmers have to find a needle in a stack of hay.
Well, to make it easy for android programmers, SonyExperia Developers have generated a tool that will process the RAW bugReport into a cleaner and more understandable format.
It is a command line tool which parses and converts android bugreport files into more human readable HTML reports. The main reason for generating the report in HTML format is, this format is comprised of text and images that is easier to read.
How to use it?
You can use the JAR file to generate the HTML report of the bugReport.
$ java -jar path/to/chkbugreport.jar thebugreport.txt
For making things easier, copy the jar file and the bug report to a location like this:
D:\Android bugreport analyzer
and use the above command to generate the HTML report.
Also if you have only a piece of bugReport for example logs or stack traces, you can still use this tool. Let’s take an example you have a system log and ANR traces.txt file, you can use this tool like this.
D:\Android bugreport analyzer>java -jar chkbugreport-0.5-215.jar -sl:the_system_log.txt -sa:traces.txt dummy
Here the “dummy” is the non-existing directory. The output will be generated in the folder called “dummy_out“.
Another example, where you have only the system logs and event logs. You can use the ChkBugReport tool like this:
D:\Android bugreport analyzer>java -jar chkbugreport-0.5-215.jar dummy --no-limit -sl:systemlog.txt -el:eventlog.txt
Now let’s see what does each option means.
- The dummy argument is used only to generate an output filename
- The –no-limit tells chkbugreport to not trunkate the log files. By default chkbugreport trunkates log files bigger then 1MB, in order to avoid generating too huge reports (or running out of memory). Sometimes this is what you want as well, if the crash/exception is at the end of the log. However in this case we want to process the whole log file.
- The -sl:file argument will load the system/main log. If you have the main log in a separate file, you can load it with -ml:file
- The -el:file argument will load the event log.
You can see the other list of options that you can use it, from here.
Examples of how the Android bugreport will look like after transformation
As you can see, it is a great tool to analyze the bugReport. I have shown you only the few information. But, you can see how this generated HTML report will looks like by following this link. If you like this post, please do share it on social media like Facebook or WhatsApp. If you have any suggestions or questions please do let me know in the comment section. Or if you want to know anything about any app or software for your own purpose, write us to email@example.com, and please like our Facebook page.