Wei's Memo

A programmer's log.

Take Screenshot of Android Devices From Command Line

I found that calabash-android is using this jar file to take screenshots.

screenshotTaker.jar

To take a screenshot:

  • You need to install android sdk tools.
  • Set ANDROID_HOME to the path of the installed sdk(or you can set it from the command line).
  • Download screenshotTaker.jar.
  • Turn on debug mode of your device and connect it to your machine through usb.
  • Run the following command:
1
java -jar screenshotTaker.jar <screenshot-filename.png> [device-args]

device-args will be forward to adb command, so you can specify the serial-no when you have multiple devices connected. For example:

1
ANDROID_HOME=/DevTools/adt-bundle-mac-x86_64/sdk/ java -jar screenshotTaker.jar a.png -s 355659040404653