One-click Analysis of Android Adb BugReport for Mobile

Source: Internet
Author: User
Keywords adb bugreport android bugreport
Tags android adb bugreport bugreport adb
In the Android system test, it is often necessary to grab the log, and the built-in BugReport function is the most convenient and comprehensive. Then the problem comes. BugReport contains a lot of information, but it becomes troublesome to analyze. Of course, it is not only me who have trouble, but also space2. The predecessor wrote an open source tool called chkbugreport for this purpose, which can directly analyze the BugReport. Well, my troubles have been solved by others. At the same time inspired by colleagues, the chkbugreport tool has been enhanced to achieve a one-click analysis of BugReport ^ _ ^, very simple, is to get the BugReport and analysis BugReport together, all take Python practice.


  1. Java environment has been configured
  2. Download chkbugreport.jar (please change the name to chkbugreport.jar after downloading)

  1. Save the following code to the same directory as chkbugreport
  2. run
  3. # -*- coding: utf-8 -*
    import os
    from subprocess import Popen, PIPE

Def devices():
    Get device information, give return value according to different status
    1. When the device is not connected, the return value is 0.
    2. When only one device is connected, the return value is 1
    3. When multiple devices are connected, the return value is 2
    Resp = Popen(
        'adb devices', shell=True, stdout=PIPE, stderr=PIPE).stdout.readlines()
    Cmd = []
    For i in resp:

    If cmd[-2] == cmd[0]:
        Print ('...... Devices not fond ......')
        Return 0
    Elif len(cmd) > 3:
        Print ('... Fond %s devices ......' %
               (len(cmd) - 2))
        Return 2
        Print ('... Device is fond ......')
        Return 1

Def analysis_bugreport():
    Get Bugreport and analyze it
    Print 'getting bugreport...'
    Os.system('adb shell bugreport > %s\\bugreport.log' % os.getcwd())
    Print 'Got it.'
    # Bugreport
    Os.system('java -jar chkbugreport.jar bugreport.log')
    Print 'Analysis complete.'

If __name__ == '__main__':
    If devices() == 1:
    # raw_input('Press Enter key to continue......')

International practice, thanks to space2, and my colleague Zheng Hong recommended chkbugreport to me.
In fact, the original blogger wrote so much, and extracted two things:

1, adb shell bugreport > bugreport.log Get the system's bugreport report

2. Place the report generated above and the downloaded chkbugreport.jar in the same directory and run java -jar chkbugreport.jar bugreport.log

Will automatically generate the corresponding html file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.