javaandroidandroid-studiopermissions

Cannot resolve method checkSelfPermission


I'm trying to make my app ready for Android 6 and now I'm stuck to the point where you need to request and check permissions.

I tried the following from the docs:

int permissionCheck = ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.WRITE_CALENDAR);

The problem is that Android Studio says Cannot resolve method 'checkSelfPermission'.

I already included the appcompat and support lib. ContextCompat is known to AS but the method itself isn't known. I don't know what am I doing wrong - in another project I can write this method and it gets recognized.

TargetAPI is 23.

Does anyone know a solution?


Solution

  • Oh my godness - what a stupid mistake.

    AS imported the supportlib as a jar and this jar was from like 2014. I just replaced the jarimport with the real dependency and know it is working.

    Thanks for your help guys!