无法登录Goolge Play游戏服务:必须具有游戏ID才能登录 [英] Can't sign in Goolge Play Game Services: Must have a game ID to sign in

查看:615
本文介绍了无法登录Goolge Play游戏服务:必须具有游戏ID才能登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试集成Google Play游戏服务,但无法登录.我知道一些开发人员以前曾问过此问题,但问题是没人问我遇到的错误.

I am trying to integrate Google Play Game Services but can't sign in. I know some developers ask about this problem before but the problem is nobody asked about the error I am encountering.

日志是这个.

必须具有游戏ID才能登录!

Must have a game ID to sign in!

状态{statusCode =未知状态码:12501,分辨率=空}

Status{statusCode=unknown status code: 12501, resolution=null}

在EXTRA_GAME_ID附加文件中找到了无效的(空)游戏ID.

Invalid (empty) game ID found in the EXTRA_GAME_ID extra.

我只是遵循官方文档上的教程. 可能导致此错误的原因是什么?似乎没人问这个错误,这很奇怪.每个人都有一些状态码,但我的只是unknown 任何人都遇到此错误吗?

I was just following the tutorial on the official doc. What is the cause of this error possibly? Seems like no one asked about this error and it's weird. Everyone got some status code but mine is just unknown Anyone have encountered this error?

Manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="...">

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:roundIcon="@mipmap/ic_launcher"
    android:theme="@style/AppTheme">

    <meta-data android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id" />
    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>
    ...

Activity

private void startSignInIntent() {
    GoogleSignInClient signInClient = GoogleSignIn.getClient(this,
            GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
    Intent intent = signInClient.getSignInIntent();
    startActivityForResult(intent, RC_SIGN_IN);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == RC_SIGN_IN) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
        if (result.isSuccess()) {
            // The signed in account is stored in the result.
            GoogleSignInAccount signedInAccount = result.getSignInAccount();
        } else {
            String message = result.getStatus().getStatusMessage();
            if (message == null || message.isEmpty()) {
                Log.e("e", result.getStatus());
                message = "Something wrong happened. Please try again.";
            }
            new AlertDialog.Builder(this, R.style.CustomAlertDialogTheme).setMessage(message)
                    .setNeutralButton(android.R.string.ok, null).show();
        }
    }
}

res/values/ids.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="app_id" type="string">digits here...</item>
</resources>

我确定我已将我的应用程序链接到Play游戏服务.我将自己添加到Play控制台(游戏服务部分以及发布管理)上的测试人员.我尝试了实际的设备和仿真器.我没有在API控制台上手动创建OAuth2客户端ID.我是从Play控制台创建的. SHA-1是正确的(如果不正确,我应该得到其他错误消息.)从未起作用.

I am sure I linked my app to Play Game Services. I added myself to tester on Play Console (Game Services section as well as Release management). I tried with both actual device and emulator. I didn't create OAuth2 client ID manually on API Console. I created it from Play Console. SHA-1 is correct (If this is incorrect I am supposed to get other error message.) Never worked.

推荐答案

我遇到了具有相同输出的问题-我将com.google.android.gms:play-services-(base/games/auth)的版本降级为16.0 .0并获得更好的错误日志:

I came across problem with same output - I downgraded version of com.google.android.gms:play-services-(base/games/auth) to 16.0.0 and got better error log:

019-10-24 11:52:03.266 25880-12410/? E/ValidateServiceOp: ****
**** APP ID IS NOT CORRECTLY CONFIGURED TO USE GOOGLE PLAY GAME SERVICES
**** Specify it using @string resources value or \u003 followed by an app_id value.
**** For example:
****   meta-data android:name="com.google.android.gms.games.APP_ID"
****             android:value="@string/app_id" />
**** or
****   meta-data android:name="com.google.android.gms.games.APP_ID"
****             android:value="\u003123456789" />

我的清单是这样的:

android:name="com.google.android.gms.games.APP_ID"
****             android:value="3123456789" />

我缺少\u003符号.将其替换为@string/app_id并将值添加到strings.xml后,它开始工作.您将此字符串添加到了ids.xml,这可能是错误的.

I had missing \u003 symbol. After replacing this with @string/app_id and putting value to strings.xml it started working. You added this string to ids.xml, which may be wrong.

这样做之后,我升级了Google Play服务版本,一切正常!

After doing that I upgraded version of Google Play Services and everything works!

这篇关于无法登录Goolge Play游戏服务:必须具有游戏ID才能登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆