til

Record Android Screen with ADB

I use this to record demos. Before I knew about this, I used Mac’s Cmd + Shift + 5.

https://developer.android.com/tools/adb#screenrecord

adb shell screenrecord /sdcard/video.mp4
adb pull /sdcard/file.mp4 .

If I run it in the background, I can get its process id like this to kill it.

adb shell screenrecord /sdcard/video.mp4 &
pid=$!
...
kill $pid

This worked on MacOS, but not in GitHub Actions, as seen in this commit and run. I wonder if it’s because of /usr/bin/sh -c. It was run in a script block of android-emulator-runner. I ended up using Maestro’s startRecording instead.