Capture and Analyze Android Battery Usage with Battery Historian

14 min read Learn step‑by‑step how to record battery statistics on any Android phone and use Battery Historian to pinpoint apps or services that drain power, all without rooting. October 07, 2026 14:30 How to Capture and Analyze Android Battery Usage with Battery Historian (No Root)

When your phone seems to run out of juice faster than it should, the first question is what is actually consuming the power. Android records detailed battery statistics internally, but the raw data is not human‑readable. Battery Historian is an open‑source web tool that turns those logs into clear graphs, letting you see which apps, wake‑locks, or hardware components are responsible.

This tutorial assumes you have a Windows, macOS, or Linux PC and a USB cable that can transfer data. No root access is required on the phone.

Before you start

  • Charge your device to at least 50 %. Battery‑stat collection can be inaccurate on a near‑empty battery.
  • Enable Developer options and USB debugging (Settings > About phone > tap Build number 7 times, then Settings > System > Advanced > Developer options).
  • Install adb on your PC. You can download the platform‑tools zip and extract it to a folder that is in your PATH or reference it directly.
  • Make sure your PC can communicate with the phone: connect via USB, accept the RSA prompt on the device, then run adb devices to see the device listed.
  • Have a recent version of Python 3 installed (required to run Battery Historian). If you prefer not to install Python, the pre‑built JAR version can be used – the steps are included.

What Battery Historian does

Battery Historian parses the batterystats binary that Android writes every time a bug report is generated. It then displays:

  • Screen‑on/off timelines.
  • CPU wake‑locks held by each app.
  • Network activity spikes.
  • Sensor usage (GPS, accelerometer, etc.).
  • Battery level changes over time.

By correlating these events you can answer questions like:

  • Which app kept the device awake while the screen was off?
  • Did a misbehaving service cause a sudden battery drop?
  • Is the Wi‑Fi radio staying on longer than necessary?

Step 1 – Install ADB and verify the connection

  1. Download the platform-tools zip for your OS from the Android developer site.
  2. Extract the archive to C:\adb (Windows) or ~/adb (macOS/Linux).
  3. Add the folder to your PATH (optional but convenient). On Windows, open System Properties → Advanced → Environment Variables → edit Path and add the folder.
  4. Open a terminal (Command Prompt, PowerShell, Terminal, etc.) and type:
    adb version
    You should see something like Android Debug Bridge version 1.0.41.
  5. Connect your phone via USB, unlock it, and run:
    adb devices
    If the device appears as device (not unauthorized), the connection is ready.

Step 2 – Capture a battery‑stats dump

Battery Historian works with two kinds of logs: a full bug report (which includes the batterystats file) or a direct dumpsys batterystats output. The bug‑report method gives the most detail, but requires a bit more storage.

  1. Open a terminal and run the following command to start a bug report capture:
    adb bugreport bugreport.zip
    Why this matters: The command tells the device to collect a snapshot of many system logs, including the battery data, and write them into a zip file.
  2. The phone will display a progress bar. Keep the device idle for a few minutes – the longer the capture window, the richer the timeline.
  3. When the command returns, you will have bugreport.zip in the current directory. Verify it exists:
  4. ls -lh bugreport.zip
  5. If you prefer a smaller file, you can capture only batterystats with:
    adb shell dumpsys batterystats > batterystats.txt
    This creates a plain‑text file that Battery Historian can also read.

Step 3 – Install Battery Historian

Battery Historian is distributed as a .jar file that runs on any platform with Java, and a small Python helper script to launch a local web server.

  1. Make sure you have Java Runtime Environment (JRE) 8+ installed. Verify with:
    java -version
  2. Download the latest battery-historian.jar from the GitHub releases page (e.g., github.com/google/battery-historian). Save it to a folder like ~/battery-historian.
  3. If you have Python 3, you can use the helper script provided in the repo. Save run_historian.py alongside the JAR.
  4. Open a terminal in that folder and start the server:
    python3 run_historian.py
    The script launches the JAR with the command:
    java -jar battery-historian.jar
    It will output something like Serving HTTP on 0.0.0.0 port 9999 ….
  5. Open a web browser on the same computer and navigate to http://localhost:9999. You should see the Battery Historian UI.

Step 4 – Load the bug report into Battery Historian

  1. In the Battery Historian web page, click the Choose File button and select the bugreport.zip you created earlier (or batterystats.txt if you used the lightweight method).
  2. Press Upload. The tool will unzip the archive, locate the batterystats file, and start processing.
  3. After a few seconds, a timeline view appears. You’ll see a top‑level row for the overall battery level, then rows for screen state, CPU wake‑locks, network, and individual apps.
  4. Hover over any colored block – a tooltip shows the exact start/end times and the component responsible.
  5. Use the zoom controls (mouse wheel or the +/- buttons) to focus on a specific period, such as the night when you noticed rapid drain.

Step 5 – Interpreting the graphs

Battery Historian can be intimidating at first, so we’ll walk through the most common patterns.

5.1 Screen‑on vs. Screen‑off

The thick green bar at the top represents the screen state. If you see long green periods while you thought the phone was idle, an app may be preventing the screen from turning off. Check the Wake lock rows for the same timestamps.

5.2 Wake‑locks

Each app that acquires a partial or full wake‑lock gets its own row. A wake‑lock that stays active for minutes while the screen is off is a classic battery‑drain culprit. Note the app name and the duration, then consider:

  • Disabling background activity for that app (Settings > Apps > [App] > Battery > Background restriction).
  • Checking for a newer version that may have fixed a bug.

5.3 Network activity

Spikes in the “Network” row often coincide with sync services, cloud backups, or misbehaving apps constantly polling servers. If the spikes line up with a particular app’s wake‑lock, that app is likely the offender.

5.4 GPS / Sensor usage

Location‑related rows appear as purple bars. Continuous GPS use is a major drain; look for apps that hold the location sensor for long periods.

5.5 Battery level drop

The bottom‑most line shows the battery percentage over time. Sharp drops without corresponding screen activity usually indicate a hardware issue (e.g., a failing battery) or a kernel‑level bug. If the drop aligns with a software event, you have a clear target.

Common troubleshooting scenarios

Scenario 1 – No data appears after upload

  • Make sure you uploaded the bugreport.zip that contains a batterystats file. Some OEM bug reports omit this file; in that case, use the dumpsys batterystats method instead.
  • Check the browser console for errors (press F12). If you see Failed to load resource, the JAR may not have permission to read the zip – try moving the file to the same directory as the JAR.

Scenario 2 – Battery Historian crashes with a Java exception

  • Ensure you are running Java 8 or newer. Older JRE versions lack required APIs.
  • On macOS, you may need to grant the terminal full disk access (System Settings > Privacy & Security > Full Disk Access).

Scenario 3 – The timeline shows only a few seconds of data

  • Bug reports capture data only for the period while the device is generating the report. For longer‑term analysis, repeat the adb bugreport command after a few hours of normal use, then merge the two reports using the --merge flag of Battery Historian (available in newer releases).

Advanced tips and edge cases

  • Android 12+ restrictions: Starting with Android 12, the system limits how often dumpsys batterystats can be invoked without root. If you hit a permission error, use the bug‑report method instead.
  • Automating data collection: You can schedule periodic dumps with a simple shell script on your PC:
    while true; do
      timestamp=$(date +%Y%m%d_%H%M%S)
      adb shell dumpsys batterystats > "batterystats_$timestamp.txt"
      sleep 3600  # one hour interval
    done
    This creates hourly snapshots you can later load individually.
  • Using the built‑in Power Profile: Some devices expose a settings put global power_profile command that can temporarily switch to a low‑power mode for testing. Combine this with Battery Historian to see the quantitative effect.
  • Exporting the analysis: Battery Historian lets you download the rendered SVG chart via the Export PNG button. Save the image for a quick visual reference when reporting a bug to the app developer.

Safety warnings

  • Do not enable USB debugging on a device that you leave unattended in a public place – anyone with physical access could issue ADB commands.
  • When capturing a bug report, the device temporarily stores a large amount of log data in memory. Avoid doing this while the battery is critically low.
  • Never share the full bug‑report file publicly; it can contain personal data, Wi‑Fi passwords, or other sensitive information. If you need to post a snippet, extract only the batterystats section.

Wrapping up

By following the steps above you now have a repeatable workflow:

  1. Enable USB debugging.
  2. Capture a bug report (or dumpsys batterystats) after a period of typical usage.
  3. Run Battery Historian locally and load the log.
  4. Identify wake‑locks, network spikes, or sensor usage that do not match your expectations.
  5. Apply targeted fixes – restrict background activity, update or uninstall offending apps, or adjust system settings.

Because the process is entirely on‑device and uses only free, open‑source tools, you can repeat it whenever a new drain appears, without ever rooting your phone. Over time you’ll develop an intuition for the “normal” battery pattern of your device, making future problems easier to spot.

Happy debugging, and may your battery last longer!

User Comments (0)

Add Comment
We'll never share your email with anyone else.