Wednesday, 4 January 2017

Android screenshot to computer with adb


How do I use adb to get a screenshot from an Android device or emulator?

I'd like to target a specific device when more than one are connected to adb.

I already know how to open adb shell and put a device in debugging mode.


One method is the following:

  1. Get list of devices:
    adb devices -l

    You should get a list that looks like:

  2. Once you have a device identifier, such as "emulator-5554", you can use similar commands as below. (Replace "emulator-5554" with your device identifier).
    adb -s emulator-5554 shell screencap -p /sdcard/screencap.png
    adb -s emulator-5554 pull /sdcard/screencap.png
  3. (Optional) remove the last screencap from your device (in this example, named "emulator-5554"):
    adb -s emulator-5554 shell rm /sdcard/screencap.png

Other notes:

If you've only got one device accessible to adb, you can simply do the following:

adb shell screencap -p /sdcard/screencap.png
adb pull /sdcard/screencap.png
adb shell rm /sdcard/screencap.png

If you'd like to see a one-liner to do the above, check out the neat example here:


No comments:

Post a Comment