Android 6 getAccountName() Missing android.permission.GET_ACCOUNTS

前端 未结 1 1800
情书的邮戳
情书的邮戳 2021-02-19 07:50

I get the following Exception while running on a Android 6 device.

java.lang.SecurityException: Missing android.permission.GET_ACCOUNTS

This lo

1条回答
  •  野的像风
    2021-02-19 08:04

    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:

    • ACCESS_COARSE_LOCATION
    • ACCESS_FINE_LOCATION
    • ADD_VOICEMAIL
    • BODY_SENSORS
    • CALL_PHONE
    • CAMERA
    • GET_ACCOUNTS
    • PROCESS_OUTGOING_CALLS
    • READ_CALENDAR
    • READ_CALL_LOG
    • READ_CELL_BROADCASTS
    • READ_CONTACTS
    • READ_EXTERNAL_STORAGE
    • READ_PHONE_STATE
    • READ_SMS
    • RECEIVE_MMS
    • RECEIVE_SMS
    • RECEIVE_WAP_PUSH
    • RECORD_AUDIO
    • SEND_SMS
    • USE_SIP
    • WRITE_CALENDAR
    • WRITE_CALL_LOG
    • WRITE_CONTACTS
    • WRITE_EXTERNAL_STORAGE

    0 讨论(0)
提交回复
热议问题