本文介绍了罕见的异常"android.accounts.AuthenticatorException:ServiceDisabled"-这是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 错误的假设 >我的电子邮件应用程序正在使用AccountManager访问GMail(带有OAuthToken),并且工作正常(自2102年开始),不同的是,我现在有一个特殊的异常,该异常 Wrong assumptionMy email app is using AccountManager to access GMail (with OAuthToken ) and it's working fine (since 2102), except that I now have a peculiar exception that happens only with a specific Google accountThis seems to be a quite new behaviorHere is the error is:W/System.err: android.accounts.AuthenticatorException: ServiceDisabledW/System.err: at android.accounts.AccountManager.convertErrorToException(AccountManager.java:2507)W/System.err: at android.accounts.AccountManager.-wrap0(Unknown Source:0)W/System.err: at android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:2350)W/System.err: at android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69)W/System.err: at android.os.Binder.execTransact(Binder.java:697)Questions:What exactly does the "android.accounts.AuthenticatorException: ServiceDisabled" error means?Why on earth is this only happening with this google account? (and probably for some other ones, but this seems really rare as per users feedback). Should I check some Android Google account Settings for this accounts..? Which ones?So, same code goes well for about 10 accounts I tested on my Phone, and it fails with this very specific Google account! Why?FYI, I opened an issue here: https://issuetracker.google.com/issues/127454208Note:According to the owner of this account, the app was working before, and suddenly stopped working: I am in the process of investigating when it happens and if he can give me some hints about some possible actions he took at that time.Thanks beforehand for your help.Some info I gathered:I managed to debug this a bit and found that the stacktrace go further in cpp:jboolean res = env->CallBooleanMethod(mObject, gBinderOffsets.mExecTransact, code, (int32_t)&data, (int32_t)reply, flags);https://android.googlesource.com/platform/frameworks/base/+/f76a50c/core/jni/android_util_Binder.cppI found out that "res = onTransact(code, data, reply, flags);" (i.e. android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69) from AIDL) is called withcode = 2 (probably android.accounts.AccountManager.VISIBILITY_USER_MANAGED_VISIBLE = 2)data : a Parcel Objectreply : another Parcel Objectflags = 17Which seems fine, and works for all other Google accounts!I also found out that the error code in AccountManager.convertErrorToException was code ERROR_CODE_INVALID_RESPONSE 解决方案 Problem understood and solved!Since January 2019, some OAuth2 scopes are restricted.Also, the Additional Requirements for Specific API Scopes page sates: Enforcement of the requirements in this section will begin on January 15, 2019 when all new applications must undergo a new application review process before accessing certain API scopes. Applications submitted for verification before January 15, 2019 will be given a grace period to come into compliance, and must submit for re-review no later than February 15, 2019. To learn more about these new requirements, read our blog post, Elevating user trust in our API ecosystem, and the OAuth Application Verification FAQ.In order to have your Android apps being compliant with this, you must create a new "ID clients OAuth 2.0" for Android.This ID has to be created on this page https://console.developers.google.com/apis/credentialsThe odd thing is that all this seems related to G Suite and Google APIs, not Android SDK.It's probably because the OAuth part of the Android SDK uses the Google API behind the scene, more precisely, the AccountManager#getAuthToken method does use it. 这篇关于罕见的异常"android.accounts.AuthenticatorException:ServiceDisabled"-这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-06 10:34