Appium hangs when taking a screenshot. (Android)


I’m trying to take a screenshot on an Android emulator.

Selenium implementation is written in Java on a Windows host machine. Appium is running on iMac OS X Yosemite.
I have no problems taking screenshots on any of the Apple emulators or Windows based browsers but when I try to run the same code on the Android emulator, the app “hangs” and does not seem to be responding after that.

OS X Yosemite 10.10.4
Appium version: tried on both 1.4.0 and 1.4.8 (same result)
Android studio version: 1.2.2 build 141
Android emulator: Nexus 5 API 22, Lollipop x86
Emulated Performance: Use Host GPU checked
JDK installed: 1.7

Screenshot function is using Selenium’s TakesScreenshot(driver) implementation.

Appium Logs right after calling take screenshot method on android emulator:
info: JSONWP Proxy: Got response with status 200: {“sessionId”:“00034c23b73df62f4f554251ef00b5df”,“status”:0,“value”:null}

info: JSONWP Proxy: Replacing sessionId 00034c23b73df62f4f554251ef00b5df with 00034c23b73df62f4f554251ef00b5df
info: <-- POST /wd/hub/session/00034c23b73df62f4f554251ef00b5df/element/0.5411949658300728-1/submit 200 197.952 ms - 72

info: --> GET /wd/hub/session/00034c23b73df62f4f554251ef00b5df/screenshot {}

info: JSONWP Proxy: Proxying [GET /wd/hub/session/00034c23b73df62f4f554251ef00b5df/screenshot] to [GET] with body: {}

After that there is no more activity and I have to manually kill the app.

Any help would be appreciated. Thanks in advance.

Darek Z

Forgot to mention that the Android emulator starts and is responding to normal selenium commands like click a button or type text. App hangs when it hits takescreenshot portion of the code.

1 Like

Bump… Still having this problem. Anyone?

try Genymotion emulators… they much more faster and maybe do not have issue.

did you try with real device?

I know this is a slightly old topic, but with the Appium Java client 3.2.0 I am facing this issue on a real device.
I know this used to work with the older Java client 3.1.0.

Unfortunately I need the newer client for the AppiumDriverLocalService feature that was added in.

Here’s the line of code where the hang happens. I know because the previous log.debug line gets printed.

	File file  = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

And here is the Appium Server Log:

2015-11-26 09:20:03:085 - info: <-- POST /wd/hub/session/93df24a9-1b33-49c8-aea1-b3b768f21d97/element 200 1210.866 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"93df24a9-1b33-49c8-aea1-b3b768f21d97"}
2015-11-26 09:20:03:101 - info: --> GET /wd/hub/session/93df24a9-1b33-49c8-aea1-b3b768f21d97/screenshot {}
2015-11-26 09:20:03:103 - debug: executing cmd: D:\vish\adt-bundle\sdk\platform-tools\adb.exe -s TA64303N7W shell "/system/bin/rm /data/local/tmp/screenshot.png; /system/bin/screencap -p /data/local/tmp/screenshot.png "

Further debugging: look at /data/local/tmp

I took a look at the /data/local/tmp device folder. Here are the contents, their permissions and timestamps:

$ adb shell ls -l /data/local/tmp
-rw-rw-rw- shell    shell    20456741 2015-11-25 21:41 0978df74a3eeb9a231b2e0cb5a1f7e73.apk
-rw-rw-rw- shell    shell       48797 2015-10-10 03:23 AppiumBootstrap.jar
-rw-rw-rw- shell    shell        2554 2015-07-25 23:40 UIAutomatorTest.jar
drwxrwxrwx shell    shell             2015-07-25 23:36 dalvik-cache
-rw------- root     root         8529 2015-11-18 15:38 dump.xml
drwx------ shell    shell             2015-08-07 16:37 local
drwxrwxrwx shell    shell             2015-10-14 15:33 mobizen
-rw-rw-r-- root     root       379501 2015-11-18 15:38 screenshot.png
-rw-rw-rw- shell    shell       53503 2015-11-26 14:49 strings.json
-rw------- shell    shell       13965 2015-11-19 14:20 uidump.xml

As you can see, there is a file screenshot.png from about a week ago. (presumably captured by the old Appium Java client).

Next: try deleting manually using adb shell

Next - I tried deleting this file using the exact adb shell command used by Appium. Here’s the output:

vish@freeman /cygdrive/d/vish/ma-app-verification-android/appium-projects/AppiumAndroid
$ adb -s TA64303N7W shell "/system/bin/rm /data/local/tmp/screenshot.png"
override rw-rw-r-- root:root for '/data/local/tmp/screenshot.png'?


The prompt seen above is what is causing Appium to hang.

Luckily, my phone is rooted, so I was able to remove the offending screenshot manually as root:

vish@freeman /cygdrive/d/vish/ma-app-verification-android/appium-projects/AppiumAndroid
$ adb root

vish@freeman /cygdrive/d/vish/ma-app-verification-android/appium-projects/AppiumAndroid
$ adb shell rm /data/local/tmp/screenshot.png
1 Like

Try this …
Worked for me
File scrone = driver.getScreenshotAs(OutputType.FILE);
String filenameone = UUID.randomUUID().toString();
String filenameone = UUID.randomUUID().toString();
BufferedImage img =;
File targetfil = new File(“target/screenshot/” + filenameone + “.PNG”);
ImageIO.write(img, “PNG”, targetfil);

Still an issue as decribed above by @savishy, with Appium 1.4.16 on real device, using Android 5.x or 6.x, appium Java-client ver. 3.3.0

1 Like

I also had with this problem. And I found it was the adb performance issue. This link would be helpful

I am still seeing this problem on Android 1.6.0 (with Java client 4.1.2). Any other solutions? I have the recent updates to the Android studio installed and I recreated the emulator, but still this won’t go away.

Nevermind I was able to resolve this by adding the desired cap 'nativeWebScreenshot

Hi all,

I am also experiencing this same exact behavior when I use Appium and Android 5.1 running as Android Emulator locally (Or on remote provider like Sauce).

My test seems to exhibit the exact behavior as @dzborowski described in the original post with the last messages in the appium log being. This is after trying multiple versions of appium (1.53, 1.6, 1.63)

[HTTP] <-- POST /wd/hub/session/3da0990d-89b9-4aa2-8650-fe0d8b96a1f1/url 200 733 ms - 76 
[HTTP] --> GET /wd/hub/session/3da0990d-89b9-4aa2-8650-fe0d8b96a1f1/screenshot {}
[MJSONWP] Driver proxy active, passing request on via HTTP proxy
[debug] [JSONWP Proxy] Proxying [GET /wd/hub/session/3da0990d-89b9-4aa2-8650-fe0d8b96a1f1/screenshot] to [GET] with body: {}