无法解析方法checkSelfPermission [英] Cannot resolve method checkSelfPermission
问题描述
我正在尝试为Android 6准备好我的应用程序,现在我陷入了需要请求和检查权限的地步.
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.
我尝试了以下文档:
int permissionCheck = ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.WRITE_CALENDAR);
int permissionCheck = ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.WRITE_CALENDAR);
问题是Android Studio提示Cannot resolve method 'checkSelfPermission'
.
The problem is that Android Studio says Cannot resolve method 'checkSelfPermission'
.
我已经包含了appcompat和support lib. AS知道ContextCompat
,但方法本身未知.我不知道我在做什么错-在另一个项目中,我可以编写此方法,并且它会被识别.
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是23.
TargetAPI is 23.
有人知道解决方案吗?
推荐答案
哦,我的天哪-这是一个愚蠢的错误.
Oh my godness - what a stupid mistake.
AS将支持库作为jar导入,并且该jar类似于2014年.我只是将jarimport替换为实际的依赖项,并且知道它可以正常工作.
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.
感谢您的帮助!
这篇关于无法解析方法checkSelfPermission的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!