Permissions Not Working

2020-03-10 06:32发布

I've been having some odd problems with permission in Android. I am trying to just get a list of the google calendars a particular user has, but first I need to let them pick the account.

I included this line in my manifest:

<uses-permission android:name="android.permission.GET_ACCOUNTS"></uses-permission>

However I get this error:

12-26 03:26:31.004 13841 13841 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{....}: java.lang.SecurityException: caller uid 10105 lacks any of android.permission.GET_ACCOUNTS

I had tried something similar with gaining access to the undocumented Calendar API with READ_CALENDAR and WRITE_CALENDAR, but I had similar exceptions (although probably for different reasons - I thought it might be worth mentioning in case it wasn't).

Please clue me in on what I'm doing wrong!

Thanks!

2条回答
看我几分像从前
2楼-- · 2020-03-10 07:13

Either your <uses-permission> is in the wrong place (should be a child of <manifest> and a peer of <application>), or GET_ACCOUNTS is not a permission that SDK applications can hold. The documentation is singularly lousy about indicating which permissions are and are not eligible for SDK applications.

查看更多
劫难
3楼-- · 2020-03-10 07:13

Had the same problem as well, changed the target SDK version in the AndroidManifest.xml to a higher version (19). In my case the target SDK version in the manifest was 17, which is equivalent to Android 4.2.2, which in turn matched the version on my HTC One. However after changing it, the Phonegap plugin for contacts worked.

查看更多
登录 后发表回答