I get the following Exception while running on a Android 6 device.
java.lang.SecurityException: Missing android.permission.GET_ACCOUNTS
This looks like a fairly straight forward exception, but for me it's not. My manifest looks like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="..." >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application
...
The piece of code which throws this exception is the following line:
mLoggedInEmail = Plus.AccountApi.getAccountName(mGoogleApiClient);
On an android 5 device it works just fine.
Starting with Android M, API 23, you need to request some permission at runtime on top of declaring them in your manifest.
See this link for more info: https://developer.android.com/training/permissions/requesting.html
As a quick workaround, you can set your targetSdkVersion
to 22 in your build.gradle
.
Keep in mind that even with this workaround, if the user goes in setting in disable the permission for your app, your app will crash.
This is the list of permissions impacted by this new change:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With