When I try to make a screenshot in Android Studio from some of my projects (by pressing the camera icon), I get the following message:
"Unexpected error while obtaining screenshot from device: EOF"
I can make a screenshot of the same image if I click the camera icon after opening a totally different project. Is there some corrupted file associated with the project that needs to be deleted and replaced?
In my case restarting the Android Studio worked for me. Go to File --> Invalidate Caches / Restart -> Invalidate and Restart.
But for someone who still has a problem after restarting. If you have
getActivity().getWindow().addFlags(LayoutParams.FLAG_SECURE);
set (normally used to avoid screenshots), it will also prevent you from taking screenshots from Android Studio, generating the same error Unexpected Error while obtaining screenshot.I try this way it working :
Create adb_capture.txt with content
Change file name to adb_capture.bat than click run which will capture phone screen
I ran into this problem recently - everything had been working fine previously. Apparently it started when I migrated to SDK 26 a few weeks ago. This fixed it for me: - shut down Studio - rename adb.exe in Android\sdk\platform-tools to .saf - copy the older adb.exe from Android\android-sdk\platform-tools to Android\sdk\platform-tools - restart Studio
So basically replace the SDK 26 adb.exe with an older version...