One of the many steps you have to do to publish your application on Google Play, it is to take screenshots of you application. You need at least 2 screenshots per device type, meaning you will need 6 screenshots if you want to release your application on Phone, Tablet 7″ and Tablet 10″. If you have more screens to demo, you will have to screenshot them 3 times.
The first time I had to do it, I simply took screenshots of my laptop. Selecting manually the area and cropped it again to get something neat with no border. You can imagine how inefficient it was:
- take and save the screenshot
- open the picture in an image editor (The Gimp)
- crop the image to get a clean screenshot with no extra border
- save your cropped image
- repeat for every single screenshot
I thought by taking the screenshot from my computer instead of the mobile, I was at least saving the time to export the screenshot.
After changing some minor design details, I had to redo all the screenshots… My “fast” manual method suddenly seemd not so fast.
Scripting the screenshot
Scrolling the web, I discovered you can interact with your emulator using commands. And two commands make the job easily!
First, you have one to take a screenshot:
adb shell screencap /sdcard/screenshot.png
Second, one command to export the screenshot from the emulator to your computer:
adb pull /sdcard/screenshot.png
The tough part of the job was done, I simply needed to packag both commands in a bash script, with one parameter for the name of the file. Here we go:
#!/bin/bash FILENAME=$1 adb shell screencap /sdcard/$FILENAME adb pull /sdcard/$FILENAME
Now, simply call the script and find your screenshot in the folder where you called your script.
Configuring your emulator
By using the above script, all your screenshots will have exactly the same size, no border, no need to crop anything.
They will still have the top bar with the time and network. Better switching the emulator to demo mode to remove any notification icon.
Enable the Developer Mode by clicking many times on the “Build number“
Back to System, select Developer options
Access the UI demo mode
Enable both options
When creating your emulator, give space for an SD card. As you can see in the script, the screenshots are saved in the folder /sdcard.
One more thing: the default configuration share few ram with the emulator, ending with a very slow device. Try giving 3 or 4 GB of RAM and 512 MB of VM Heap, you emulator will be way faster. If your computer is short in resource, as you are at the stage of taking screenshots, most likely you don’t need your IDE and many of the other tools that are currently opened. Free some RAM to your emulator and do the screenshots in 1 minute instead of struggling with it…