5

I tried the one liner solution to capture screenshot via adb and the file is created successfully on PC but it is unreadable:

 C:\Program Files\Android\android-sdk\platform-tools>adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > c:\users\utilisateur\desktop\android_screenshot1.png

enter image description here

The file seem to be correct but I think the Magic is not correct: enter image description here

EDIT: The same issue happened with Git Bash for Windows.

M. A.
  • 424
  • 6
  • 21

3 Answers3

9
adb exec-out screencap -p > screen.png

will save it on your machine directly

4

@Passella answer worked for me with a little tweaking:

adb shell screencap -p "/mnt/sdcard/output.png" && adb pull "/mnt/sdcard/output.png" "C:\output.png" && adb shell rm "/mnt/sdcard/output.png"

I had to quote the paths and replace | with &&.

Also, if you are using a Genymotion simulator, it's better to use its own adb:

C:\"Program Files"\Genymobile\Genymotion\tools\adb shell screencap -p "/mnt/sdcard/output.png" && C:\"Program Files"\Genymobile\Genymotion\tools\adb pull "/mnt/sdcard/output.png" "C:\output.png" && C:\"Program Files"\Genymobile\Genymotion\tools\adb shell rm "/mnt/sdcard/output.png"
Community
  • 1
  • 1
gabrielmaldi
  • 2,072
  • 2
  • 23
  • 36
1

Try this:

adb shell screencap -p /mnt/sdcard/output.png | adb pull /mnt/sdcard/output.png C:\output.png | adb shell rm /mnt/sdcard/output.png
kguest
  • 3,759
  • 3
  • 29
  • 31
Passella
  • 580
  • 7
  • 22