本文介绍了无法解析方法 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.

我从文档中尝试了以下内容:

I tried the following from the docs:

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 和支持库.ContextCompat 为 AS 所知,但方法本身未知.我不知道我做错了什么 - 在另一个项目中我可以编写这个方法并且它得到了认可.

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 将 supportlib 作为 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 18:42