I am getting below error while capturing screenshot in Android Studio 2.0. I tried with 2 different tablets and with both of them I am getting this error.
Unexpected Error while obtaining screenshot - java.lang.Nullpointerexception
I have googled and also looked at different stackoverflow questions but didnt found any which can resolve this issue.
I have recently installed Android Studio 2.0 and this could be a problem I dont know.
This is an old question but there is another specific reason why this can happen, and while it is clearly not OP's case, it might still help someone else:
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
.
Restarting the Android Studio worked for me.
It doesn't give the screen capture error after I restarted Android studio.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With