java - 无法登录 Google Play 游戏服务 : Must have a game ID to sign in

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

我正在尝试集成 Google Play 游戏服务,但无法登录。我知道之前有一些开发人员询问过这个问题,但问题是没有人询问我遇到的错误。

日志是这样的

Must have a game ID to sign in!

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

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

我只是按照官方文档上的教程进行操作。 这个错误的原因可能是什么?似乎没有人问过这个错误,这很奇怪。每个人都有一些状态码,但我的只是 unknown 有人遇到过这个错误吗?

代码

list

<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 是正确的(如果这不正确,我应该会收到其他错误消息。)从未奏效。

最佳答案

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

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" />

我的 list 是这样的:

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

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

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

关于java - 无法登录 Google Play 游戏服务 : Must have a game ID to sign in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57535377/

相关文章:

java - JButton 助记符仅在 ALT 键上有下划线

java - 如何在 Java 中反转数组

android - 如何防止Service被破坏

android - 使用 aSmack 为 XMPP 群聊创建 MUC 房间时发生 ClassCastException

android - Google 登录始终返回 false

android - 将 google play 服务库添加到 Cordova

java.net.Socket > InputStream > BufferedReader.read(char[]) 阻塞线程

java - Java Servlet Google App Engine 中的编码

java - 在类上使用 @DirtiesContext 注释究竟意味着什么?

c++ - 如何在已经使用适用于 C++ 的 Google Play 游戏服务 SDK 实现排行榜的情况下创建 Google+ Plus One 按钮?