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.
log.debug(filePath);
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'?
(drum-roll)
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