【问题标题】:Google Games APIs requires games_lite functionGoogle 游戏 API 需要 games_lite 函数
【发布时间】:2018-04-04 16:47:41
【问题描述】:

我使用 Google Play 游戏服务。我从官方示例中获取了代码。尝试使用 API 27 和 API 17。

所有内容都只能在一个帐户(所有者 Google 开发者控制台)下工作,在任何其他帐户下 - 不可以。

我明白了:

E/AndroidRuntime: FATAL EXCEPTION: GoogleApiHandler
java.lang.IllegalStateException: Games APIs requires https://www.googleapis.com/auth/games_lite function.
    at com.google.android.gms.common.internal.zzbq.zza(Unknown Source)
    at com.google.android.gms.games.internal.GamesClientImpl.zzb(Unknown Source)
    at com.google.android.gms.common.internal.zzab.<init>(Unknown Source)
    at com.google.android.gms.common.internal.zzab.<init>(Unknown Source)
    at com.google.android.gms.games.internal.GamesClientImpl.<init>(Unknown Source)
    at com.google.android.gms.games.Games$zzb.zza(Unknown Source)
    at com.google.android.gms.common.api.GoogleApi.zza(Unknown Source)
    at com.google.android.gms.common.api.internal.zzbo.<init>(Unknown Source)
    at com.google.android.gms.common.api.internal.zzbm.zzb(Unknown Source)
    at com.google.android.gms.common.api.internal.zzbm.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:153)
    at android.os.HandlerThread.run(HandlerThread.java:60)

我检查了所有内容,并以described here.

我的毕业生:

def gmsVersion = '12.0.1'
implementation "com.google.android.gms:play-services-games:$gmsVersion"
implementation "com.google.android.gms:play-services-auth:$gmsVersion"
implementation "com.google.android.gms:play-services-base:$gmsVersion"
implementation "com.google.android.gms:play-services-identity:$gmsVersion"

isGooglePlayServicesAvailable = SUCCESS

我花了很长时间寻找解决方案,但没有找到。

【问题讨论】:

  • 您是否包含了 SO post 中提到的 Games.SCOPE_GAMES_LITE 范围?
  • 糟糕,我不专心。非常感谢!

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


【解决方案1】:

真正的路径是requestScopes(Games.SCOPE_GAMES_LITE)

GoogleSignInOptions gso = new GoogleSignInOptions
    .Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
    .requestScopes(Games.SCOPE_GAMES_LITE)
    .requestEmail()
    .build();

【讨论】:

  • 我有一个异常 com.google.android.gms.common.api.ApiException: 12501。我应该设置 .requestIdToken(getString(R.string.default_web_client_id)) 吗?
  • requestEmail 并不是真正需要的
  • anivaler:使用 APIExcepton 您可以获得错误(状态)代码:ex.getStatusCode()。这是可以告诉您发生了什么的 CommonStatusCodes 常量之一。 getMessage() 也可能有用。
【解决方案2】:

关注这个谷歌游戏文档就足够了:https://developers.google.com/games/services/android/signin

你应该使用:

GoogleSignInOptions gso = new GoogleSignInOptions
   .Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
   .requestEmail()
   .build();

【讨论】:

  • 嗨@geisterfurz007,感谢您的反馈。我在答案中添加了一些上下文。无需将其标记为无效,因为这会使人们感到困惑。
  • 已删除评论并撤回标记。感谢您更新答案!
【解决方案3】:

我遇到了同样的问题。

在我的例子中,它发生在我在我的谷歌控制台中添加一个新的开发者时。
当在控制台中进行一些更改时,即使谷歌立即给了我们一个绿旗,它也需要一些时间才能被激活。我的问题得到了解决,我什么都不做,只需要等待几个小时。

请注意,根据Developer's Blog

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(
               GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build();

对于Games Lite scope 来说已经足够了。

注意:这是截至 2018 年 11 月 14 日

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多