Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UI Automator Viewer: receiving "Error taking device screenshot: null" every time from AVD device

This only happends on the AVD devices within the AVD manager. I never get this error when capturing uiautomatorviewer screenshots from Genymotion.

When attempting to capture within the Android Device Monitor in AS...it gives me a little more detail: Reason: Error obtaining UI hierarchy

enter image description here

like image 581
Tim Boland Avatar asked Sep 13 '14 00:09

Tim Boland


2 Answers

Try it with HAXM acceleration turned off, if you can. I had to run the test using a profile that then ran the test on a physical device to get the screen shots. Essentially, if the AVD has Use GPU or Snapshot selected - even if running on a USB attached device, screenshots fail. This is a bug in uiautomator according to the developers involved with maturing the Appium platform.

like image 167
Houston Haynes Avatar answered Oct 25 '22 08:10

Houston Haynes


In addition to answer given by Houston Haynes, the problem can happen if you have set the flags for your activity like this:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);

You can just comment the code and take the screenshots via anything(Android Studio, uiatutomatorviewer etc). Hope it helps!!

like image 32
Ajinkya Lokhande Avatar answered Oct 25 '22 08:10

Ajinkya Lokhande