Note: Many newer Android 10+ tablets have the ability to record the screen from the Quick Settings panel. Read this Google help page for information about that. This guide is for devices that do not have this feature enabled.
This article explains how to use the Android Debug Bridge adb
to record a video of your screen and save it as an mp4.
While testing a new feature for our Android app at work, I needed to record the screen to share a bug with the team. Refusing to install a shady third party screen recording app on my Galaxy Tab A 8” 2019 tablet, I decided to use the Android SDK tools as a fun and safe alternative. Here are my notes on that in case it helps others (and myself) in the future.
Install the Android Debug Bridge (adb
)
The choice is yours – one is very heavy and one is extremely light.
If you install the platform tools, you’ll need to unzip them, move the containing directory and/or symlink the individual binaries somewhere logical like /usr/local/bin
, $HOME/bin
, or $HOME/Applications
, and then add that path to your $PATH
if it’s not already there.
Here’s a nice resource for installing the SDK tools via your favorite package manager: https://guides.codepath.com/android/installing-android-sdk-tools. That said, I received a discontinuation notice while installing the android-sdk via homebrew:
android-sdk has been officially discontinued upstream. It may stop working correctly (or at all) in recent versions of macOS.
In the end I decided to go with the official Android SDK Platform Tools installation.
Prepare Your Device for Debugging
As stated in Google’s “Configure on-device developer options” document, enable the Developer Options panel by finding the build version and tapping it 5-7 times:
- Android 9 (API level 28) and higher: Settings > About Phone > Build Number
- Android 8.0.0 (API level 26) and Android 8.1.0 (API level 26): Settings > System > About Phone > Build Number
- Android 7.1 (API level 25) and lower: Settings > About Phone > Build Number
Go into the Developer Options panel and enable USB debugging:
- Android 9 (API level 28) and higher: Settings > System > Advanced > Developer Options > USB debugging
- Android 8.0.0 (API level 26) and Android 8.1.0 (API level 26): Settings > System > Developer Options > USB debugging
- Android 7.1 (API level 25) and lower: Settings > Developer Options > USB debugging
Connect your device via USB and pop open a terminal. Allow your device to connect by accepting the prompt on your device.
Now list the connected Android devices:
$ adb devices
List of devices attached
A0BCD0EFGHI device
If you see your device in the list and not the word unauthorized
next to it, continue to the next section.
If you don’t see your device, try reconnecting it, rebooting it, or swapping USB ports or cables. I ran into the latter issue when using a defective or power-only USB cable.
If you see unauthorized
next to your device, try restarting the adb server by typing the following commands:
$ adb devices
List of devices attached
A0BCD0EFGHI unauthorized
$ adb kill-server
$ adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
If you are still stuck, Google to the rescue! Sorry…
Recording the Screen
You can create a video of your screen using the adb shell screenrecord
function (see the adb shell screenrecord
documentation here).
To record the screen type:
$ adb shell screenrecord --verbose /sdcard/video.mp4
Main display is 1280x800 @60.00fps (orientation=1)
Configuring recorder for 1280x800 video/avc at 20.00Mbps
Content area is 1280x800 at offset x=0 y=0
Press control+c
or command+c
to stop the recording.
Some useful command-line options include:
Flag | Description |
---|---|
--size widthxheight |
Specify the video size |
--bit-rate |
Set the video bitrate in Mbps |
--time-limit |
Set a time limit (current max/default is 3 minutes) |
--verbose |
Display output while recording otherwise the command will be silent. |
Transfer the video to your Desktop using the following command:
$ adb pull /sdcard/video.mp4 ~/Desktop
/sdcard/video.mp4: 1 file pulled, 0 sk...ed. 22.5 MB/s (306109 bytes in 0.013s)
// Not sure why `skipped` is `sk..ed`?!
Conclusion
It’s always refreshing when you don’t need to use unknown and untrustworthy apps to do common tasks like screen recording. Hope this works out for you as well!