Does anyone have any idea about com.google.android.gms.common.api.ApiException: 16?

时间:2018-09-18 20:14:08

标签: android firebase google-signin googlesigninapi

I am getting a rather strange ApiException when trying to sign into a Google account from my application. I can reproduce this only on a device that is in Alpha testing that has had a previous version of the application (without Google sign in option). If I do a clean install on an emulator or a real device there is no problem getting authenticated. It might be messed up from some of the previous (faulty) versions that were in Alpha testing and I don't want to reinstall it on this device as it is the only way I can currently reproduce it.

According to Google's documentation, the value I get is:

public static final int CANCELED: The result was canceled either due to client disconnect or cancel(). Constant Value: 16

I can assure you that this doesn't happen explicitly neither in the code nor by me when testing it. As I said, I have already tested it on one other physical device and on several emulated devices and I can authenticate multiple accounts fine.

Has anyone faced this error and does anyone have any ideas as to why might I get it?

Sorry for the way I attached the logs but I can't get them any other way:

enter image description here

1 个答案:

答案 0 :(得分:0)

事实证明,如果将应用程序部署在Google Play商店中,则SHA1签名密钥与从Android Studio生成的密钥不同(文档指出您应该使用该密钥)。

要解决此问题,我要做的就是找到我的应用程序的SHA1应用程序签名证书(从Google Play控制台:发行管理->应用程序签名),并使用此密钥在云控制台中创建新的OAuth2 Android凭据,如下所示:并将其添加到项目设置下的Firebase控制台中。