← All posts

Two small adb tools for documenting Android bugs

I recently began work on a new machine without administrator rights, and while I waited for access to the codebase I found defects on a device that I wanted to report. A useful defect report needs evidence: a screenshot of each step and a recording of the failure.

I would normally capture both in Android Studio. It was installed, but I could not open a project in it. Git on macOS refuses to run until the Xcode licence has been accepted, and accepting the licence requires administrator rights. Without a project, the screenshot and recording tools were not available to me.

The Android SDK was still on the machine, and with it adb, which can capture screenshots and video from a connected device. That was enough to work with. Directing Claude as a coding agent, I set one narrow objective first: record a video of the device from the terminal. Two tools grew from that starting point, and both are now public in my android-tools repository.

adb-record

Once a single recording worked, we turned the commands into a script and then refined it, adding the options that make it practical for daily use. The result starts a recording with one command:

adb-record checkout-crash
Recording Pixel 8... press Enter (or Ctrl+C) to stop.

Pulling video...
Saved: /Users/you/Desktop/checkout-crash.mp4

The first line appears as recording begins, and the terminal then waits. Pressing Enter stops the recording, and the script transfers the video from the device to the Desktop.

The recorder in Android Studio is capable, but it is a graphical tool, so reproducing a defect means dividing attention between the mouse, the keyboard and the device. With adb-record, one hand stays on the keyboard and the other on the device.

There has been a second, unplanned benefit. Recordings I made in Android Studio occasionally contained sections that played in slow motion, a symptom of variable frame rate timing in the file, and I could not predict when it would occur. No recording made with adb-record has shown the problem so far.

adb-shot

I then applied the same approach to screenshots, and this is where the larger improvement came.

The screenshot tool in Android Studio captures one image at a time. Each image opens in Preview and has to be named and saved individually. That is acceptable for a single screenshot. It is slow for a defect that takes several steps to reproduce, where every step needs its own image.

adb-shot takes the name and the number of steps once, then captures a screenshot each time Enter is pressed:

adb-shot -n 3 checkout-steps
Shot 1/3: press Enter to capture...
Saved: /Users/you/Desktop/checkout-steps-1.png
Shot 2/3: press Enter to capture...
Saved: /Users/you/Desktop/checkout-steps-2.png
Shot 3/3: press Enter to capture...
Saved: /Users/you/Desktop/checkout-steps-3.png
Copied to clipboard.

The output is a numbered, consistently named set of files, produced without a single dialog. A single screenshot works the same way, without the count.

A workaround that became the process

Waiting for access could have been idle time. It produced working software instead: two documented, public tools that are useful on any Android project. They began as a substitute for tools I could not reach, they have proved more capable than the process they replaced, and I now use them by choice.

Both are shell scripts for macOS. They need only adb on the PATH and a device with USB debugging enabled. Clone the android-tools repository and run ./install.sh. Each tool lists its options with -h.