为什么我有Android Google Play帐号选择器循环?

时间:2014-05-28 14:54:57

标签: android google-play-services google-play-games

我想在我的Android应用程序中实现Google Play服务。 我已在那里实施manual sign in - 用户应按GameSignInActivity中的按钮登录。

但它并没有像预期的那样发挥作用。当我按下登录按钮时,它会显示要选择的帐户列表。选择一个帐户并按下确定后,它会关闭其活动,然后再次显示一个帐户选择器(它会一次又一次地发生)。

这是日志:

05-28 18:39:54.329: W/BaseGameActivity(31235): BaseGameActivity.enabledDebugLog(bool,String) is deprecated. Use enableDebugLog(boolean)
05-28 18:39:54.329: D/GameHelper(31235): GameHelper: Debug log enabled.
05-28 18:39:54.329: D/GameHelper(31235): GameHelper: Setup: requested clients: 1
05-28 18:39:54.909: D/GameHelper(31235): GameHelper: onStart
05-28 18:39:54.909: D/GameHelper(31235): GameHelper: Connecting client.
05-28 18:39:55.170: D/GameHelper(31235): GameHelper: onConnectionFailed
05-28 18:39:55.170: D/GameHelper(31235): GameHelper: Connection failure:
05-28 18:39:55.170: D/GameHelper(31235): GameHelper:    - code: SIGN_IN_REQUIRED(4)
05-28 18:39:55.180: D/GameHelper(31235): GameHelper:    - resolvable: true
05-28 18:39:55.180: D/GameHelper(31235): GameHelper:    - details: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{4052a0c0: android.os.BinderProxy@40526538}}
05-28 18:39:55.180: D/GameHelper(31235): GameHelper: onConnectionFailed: Will NOT resolve; not user-initiated and max attempts reached: 1 >= 0
05-28 18:39:55.180: D/GameHelper(31235): GameHelper: onConnectionFailed: since we won't resolve, failing now.
05-28 18:39:55.180: D/GameHelper(31235): GameHelper: Notifying LISTENER of sign-in FAILURE (no error)
05-28 18:39:55.180: I/GameSignInActivity(31235): Sign in failed
05-28 18:39:55.200: I/ActivityManager(559): Displayed org.myapp/.GameSignInActivity: +946ms

05-28 18:40:12.907: I/GameSignInActivity(31235): Begin user sign in
05-28 18:40:12.917: D/GameHelper(31235): GameHelper: beginUserInitiatedSignIn: resetting attempt count.
05-28 18:40:12.957: D/GameHelper(31235): GameHelper: Starting USER-INITIATED sign-in flow.
05-28 18:40:12.967: D/GameHelper(31235): GameHelper: beginUserInitiatedSignIn: continuing pending sign-in flow.
05-28 18:40:12.997: D/GameHelper(31235): GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{4052a0c0: android.os.BinderProxy@40526538}}
05-28 18:40:13.007: D/GameHelper(31235): GameHelper: Result has resolution. Starting it.
05-28 18:40:13.007: I/ActivityManager(559): Starting activity: Intent { flg=0x4000000 cmp=com.google.android.gms/.games.ui.signin.SignInActivity (has extras) } from pid -1
05-28 18:40:13.257: I/ActivityManager(559): Start proc com.google.android.gms.ui for activity com.google.android.gms/.games.ui.signin.SignInActivity: pid=31502 uid=10033 gids={3003, 1015, 1006, 1007, 2001, 3002, 3001}
05-28 18:40:13.507: I/MultiDex(31502): load(/data/app/com.google.android.gms-1.apk, forceReload=false)
05-28 18:40:13.638: I/MultiDex(31502): Need extracted file /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-1.apk.classes2.zip
05-28 18:40:13.638: I/MultiDex(31502): No extraction needed for /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-1.apk.classes2.zip of size 1897418
05-28 18:40:13.728: D/GCM(24534): GcmService start Intent { act=com.google.android.gms.INITIALIZE pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService } com.google.android.gms.INITIALIZE
05-28 18:40:14.328: I/ActivityManager(559): Displayed com.google.android.gms/.games.ui.signin.SignInActivity: +1s83ms (total +17s59ms)
05-28 18:40:18.612: I/ActivityManager(559): Starting activity: Intent { act=com.google.android.gms.common.account.CHOOSE_ACCOUNT flg=0x20000000 pkg=com.google.android.gms cmp=com.google.android.gms/.common.account.AccountPickerActivity (has extras) } from pid 31502
05-28 18:40:18.973: D/GameHelper(31235): GameHelper: onStop
05-28 18:40:18.973: D/GameHelper(31235): GameHelper: Client already disconnected when we got onStop.
05-28 18:40:18.993: I/ActivityManager(559): Displayed com.google.android.gms/.common.account.AccountPickerActivity: +310ms
05-28 18:40:21.395: D/GameHelper(31235): GameHelper: onStart
05-28 18:40:21.395: D/GameHelper(31235): GameHelper: Connecting client.
05-28 18:40:21.565: D/GameHelper(31235): GameHelper: onConnectionFailed
05-28 18:40:21.565: D/GameHelper(31235): GameHelper: Connection failure:
05-28 18:40:21.585: D/GameHelper(31235): GameHelper:    - code: SIGN_IN_REQUIRED(4)
05-28 18:40:21.595: D/GameHelper(31235): GameHelper:    - resolvable: true
05-28 18:40:21.595: D/GameHelper(31235): GameHelper:    - details: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{405ecb30: android.os.BinderProxy@40526538}}
05-28 18:40:21.595: D/GameHelper(31235): GameHelper: onConnectionFailed: WILL resolve because user initiated sign-in.
05-28 18:40:21.595: D/GameHelper(31235): GameHelper: onConnectionFailed: resolving problem...
05-28 18:40:21.595: D/GameHelper(31235): GameHelper: resolveConnectionResult: trying to resolve result: ConnectionResult{statusCode=SIGN_IN_REQUIRED, resolution=PendingIntent{405ecb30: android.os.BinderProxy@40526538}}
05-28 18:40:21.595: D/GameHelper(31235): GameHelper: Result has resolution. Starting it.
05-28 18:40:21.625: I/ActivityManager(559): Starting activity: Intent { flg=0x4000000 cmp=com.google.android.gms/.games.ui.signin.SignInActivity (has extras) } from pid -1
05-28 18:40:25.569: I/ActivityManager(559): Starting activity: Intent { act=com.google.android.gms.common.account.CHOOSE_ACCOUNT flg=0x20000000 pkg=com.google.android.gms cmp=com.google.android.gms/.common.account.AccountPickerActivity (has extras) } from pid 31502

我该怎么办才能修复它?

P.S。对于我的应用,android:minSdkVersion7,我使用android 2.3在设备上测试该应用。我也使用android-support-v4.jar lib。 我没有运行android 4.4.2的模拟器出现这样的问题。

1 个答案:

答案 0 :(得分:0)

在我查看LogCat之前,我遇到了同样的问题:

Unexpected response code 403 for https://www.googleapis.com/games/v1/players/[longNumber]?language=en_US
Access Not Configured. Please use Google Developers Console to activate the API for your project.
...
Unable to sign in - application does not have a registered client ID

原来我签署了应用程序,然后生成了一个SHA1密钥,但后来使用了更新的AndroidSDK并更改了SHA1密钥,因此开发人员控制台无法识别它。查看您的日志,看看是否有相同的错误,如果是,请从控制台中删除您的应用并重新签名。

如果您之前没有授权,可以查看this guide,这很有帮助