Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Unexpected Error while obtaining screenshot - java.lang.nullpointerexception

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.

like image 989
Nirali Avatar asked Jan 07 '23 02:01

Nirali


2 Answers

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.

like image 117
Logain Avatar answered Jan 11 '23 01:01

Logain


Restarting the Android Studio worked for me.

It doesn't give the screen capture error after I restarted Android studio.

like image 44
Nirali Avatar answered Jan 11 '23 03:01

Nirali