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.
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.adb devices to see the device listed.Battery Historian parses the batterystats binary that Android writes every time a bug report is generated. It then displays:
By correlating these events you can answer questions like:
platform-tools zip for your OS from the Android developer site.C:\adb (Windows) or ~/adb (macOS/Linux).PATH (optional but convenient). On Windows, open System Properties → Advanced → Environment Variables → edit Path and add the folder.adb version
You should see something like Android Debug Bridge version 1.0.41.adb devices
If the device appears as device (not unauthorized), the connection is ready.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.
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.bugreport.zip in the current directory. Verify it exists:ls -lh bugreport.zip
adb shell dumpsys batterystats > batterystats.txt
This creates a plain‑text file that Battery Historian can also read.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.
java -version
battery-historian.jar from the GitHub releases page (e.g., github.com/google/battery-historian). Save it to a folder like ~/battery-historian.run_historian.py alongside the JAR.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 ….http://localhost:9999. You should see the Battery Historian UI.bugreport.zip you created earlier (or batterystats.txt if you used the lightweight method).batterystats file, and start processing.Battery Historian can be intimidating at first, so we’ll walk through the most common patterns.
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.
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:
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.
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.
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.
bugreport.zip that contains a batterystats file. Some OEM bug reports omit this file; in that case, use the dumpsys batterystats method instead.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.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).dumpsys batterystats can be invoked without root. If you hit a permission error, use the bug‑report method instead.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.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.Export PNG button. Save the image for a quick visual reference when reporting a bug to the app developer.batterystats section.By following the steps above you now have a repeatable workflow:
dumpsys batterystats) after a period of typical usage.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!









