GET_ACCOUNTS权限和Google API的

时间:2018-10-03 20:59:46

标签: android google-api android-permissions google-auth-library

我正在使用Gmail API从Android应用发送电子邮件。
阅读有关GET_ACCOUNTS权限的信息,使我认为它不再是必需的,但显然,我错了。

我个人使用Android 8,并且没有声明权限就可以正常工作,但是,运行Android 7会从Google GMS Auth lib引发一个异常:(我知道,该异常看起来并不相关,这是权限问题)

java.lang.IllegalArgumentException: the name must not be empty: null
    at android.accounts.Account.<init>(Account.java:48)
    at com.google.android.gms.auth.zzd.getToken(Unknown Source)
    at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
    at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:267)
    at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:292)
    at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:868)
    at com.google.api.client.googleapis.media.MediaHttpUploader.executeCurrentRequestWithoutGZip(MediaHttpUploader.java:545)
    at com.google.api.client.googleapis.media.MediaHttpUploader.executeCurrentRequest(MediaHttpUploader.java:562)
    at com.google.api.client.googleapis.media.MediaHttpUploader.executeUploadInitiation(MediaHttpUploader.java:519)
    at com.google.api.client.googleapis.media.MediaHttpUploader.resumableUpload(MediaHttpUploader.java:384)
    at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:336)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:427)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)

所以我想我仍然需要声明它,并要求用户在Android 7上授予它,但还要使用其他哪些SDK版本?
看起来Android 8不需要许可,但是Android 6向下版本又如何呢?
我看过Google API的所有文档,但没有发现任何相关的信息...

0 个答案:

没有答案