Google Play游戏服务未能登录 [英] Google Play Game Service failing to sign in

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

问题描述

我已经把头撞在墙上了好几天了。尽管阅读了许多文章描述了GPS登录失败的许多问题/解决方案,但我一直无法找到解决我的问题的办法。



总之,我正在开发一款游戏在Android Studio中使用LibGDX框架并添加了BaseGameUtils作为库并添加了所有必要的依赖关系等。

问题陈述:当游戏启动时,它会尝试连接到GPGS,但始终以登录失败消息进行响应。 logcat包含以下消息:

  01-03 19:37:41.744 6693-7436 /? E / TokenRequestor:您有错误的OAuth2相关配置,请检查。详细错误:UNREGISTERED_ON_API_CONSOLE 
01-03 19:37:41.764 20609-20609 /? I / SignInActivity:从6跳转到11
01-03 19:37:41.764 20609-20609 /? W / SignInActivity:onSignInFailed()...
01-03 19:37:41.764 20609-20609 /? W / SignInActivity:在6
01-03 19:37:41.764 20609-20609 /?期间登录失败W / SignInActivity:==>返回不良结果:10002

根据 https://developers.google.com/android/reference/com/google/android/gms/games/ GamesActivityResultCodes ...

  public static final int RESULT_SIGN_IN_FAILED 

返回的结果代码登录时调用活动失败。

尝试登录游戏服务失败。
例如,如果网络不稳定,
或用户帐户被禁用,或者无法获得同意,则可能发生这种情况。

常数值:10002

我的网络不是'薄片',我不相信我的帐户已被禁用 - 我已经安装的其他商业游戏与GPGS一起工作得很好。



我已经签署了APK - 调试和发布在这个阶段只能用于调试)。我已将该游戏添加到Google Developer Console中,并将其链接到API管理器中,并创建了OAuth2客户端ID。事实上,我已经做了很多次这样的事情,删除链接的游戏并重新创建它,认为我的客户端ID或SHA1指纹不正确。 logcat消息表明OAuth2配置是错误的,但我已经检查了很多次,这一切对我来说都很好。验证签名的最佳方式是什么?



我正在测试一个物理的三星S7,我直接从笔记本电脑部署。我的Android Gradle具有必要的SigningConfigs声明,所以我相信我的已部署的游戏应该正确签名。

  android {
signingConfigs {
config {
keyAlias'mygame-key'
keyPassword'mypassword'
storeFile文件('path / to / my / keystore.jks')
storePassword' keystorepassword'
}
}
buildTypes {
release {
signingConfig signingConfigs.config
}
debug {
signingConfig signingConfigs。 config
debuggable true


$ c
$ b

在我的清单中,我有必需的行。例如。 -

 <使用权限android:name =android.permission.INTERNET/> 
< uses-permission android:name =android.permission.ACCESS_NETWORK_STATE/>
< meta-data android:name =com.google.android.gms.games.APP_IDandroid:value =@ string / app_id/>
< meta-data android:name =com.google.android.gms.versionandroid:value =@ integer / google_play_services_version/>

最初,在AndroidLauncher中,我使用的是GameHelper类,但最近发现它已被弃用,所以我将我的代码更改为使用GoogleApiClient。构建器的定义如下:

  mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.build();

其他方法的代码直接来自TrivialQuest示例应用程序,例如 -

  @Override 
保护无效onStart(){
Log.d(TAG,onStart ));
super.onStart();
mGoogleApiClient.connect();
}

然而,尽管使用Google API客户端代码,但这并没有什么区别。

我不确定此处还提供了什么,但请告诉我是否需要查看代码的其他部分。我会非常感谢任何关于在代码或日志中检查的东西的建议,以便更好地了解为什么这样做会失败。



非常感谢您提前致谢。

我认为你应该仔细阅读(或重新阅读)所有描述的过程 .google.com / games / services / console / enablerel =nofollow noreferrer>这里
如果您在再次从头开始学习教程后需要更多帮助,请添加注释。



90%的问题涉及:错误sha1签名证书,错误的应用程序包名称,缺少客户端ID以及类似的内容......



PS:这里你可以找到所有的工作样本


I have been banging my head against the wall over this for a number of days now. Despite reading many posts describing numerous problems/solutions to GPS sign-in failure I have been unable to find a solution to my problem.

In short, I am developing a game in Android Studio using the LibGDX framework and have added BaseGameUtils as a library and added all the necessary dependencies etc.

Problem Statement: When the game starts, it attempts to connect to GPGS but always responds with a 'Failed to log in' message. The logcat contains the following message:

01-03 19:37:41.744 6693-7436/? E/TokenRequestor: You have wrong OAuth2 related configurations, please check. Detailed error: UNREGISTERED_ON_API_CONSOLE
01-03 19:37:41.764 20609-20609/? I/SignInActivity: Transition from 6 to 11
01-03 19:37:41.764 20609-20609/? W/SignInActivity: onSignInFailed()...
01-03 19:37:41.764 20609-20609/? W/SignInActivity: Sign in failed during 6
01-03 19:37:41.764 20609-20609/? W/SignInActivity: ==> Returning non-OK result: 10002

According to https://developers.google.com/android/reference/com/google/android/gms/games/GamesActivityResultCodes ...

public static final int RESULT_SIGN_IN_FAILED

Result code sent back to the calling Activity when signing in fails.

The attempt to sign in to the Games service failed.
For example, this might happen if the network is flaky,
or the user's account has been disabled, or consent could not be obtained.

Constant Value: 10002

My network is not 'flaky' and I don't believe my account has been disabled - other commercial games I have installed work perfectly fine with GPGS.

I have signed my APK - both debug and release (although I'm only working with debug at this stage). I have added the game into the Google Developer Console and linked it in the API Manager and created the OAuth2 client ID. In fact, I have done this many times, deleting the linked game and recreating it thinking that either my client ID or the SHA1 fingerprint were incorrect. The logcat message suggests that the OAuth2 configuration is wrong but I have checked this many times and it all looks okay to me. What is the best way to verify the signature?

I am testing on a physical Samsung S7 which I deploy to directly from my laptop. My Android Gradle has the necessary SigningConfigs declared so I believe my deployed game should be correctly signed.

android {
signingConfigs {
    config {
        keyAlias 'mygame-key'
        keyPassword 'mypassword'
        storeFile file('path/to/my/keystore.jks')
        storePassword 'keystorepassword'
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.config
    }
    debug {
        signingConfig signingConfigs.config
        debuggable true
    }
}

In my manifest, I have the required lines. E.g. -

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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"/>

Originally, in AndroidLauncher, I was using the GameHelper class but discovered recently that this is being deprecated, so I changed my code to use GoogleApiClient. The builder is defined as follows:

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Games.API).addScope(Games.SCOPE_GAMES)
            .build();

The code for the other methods has been taken directly from the TrivialQuest example app, e.g. -

@Override
protected void onStart() {
    Log.d(TAG, "onStart()");
    super.onStart();
    mGoogleApiClient.connect();
}

However, despite using the Google API client code, this has made no difference.

I'm not sure what else to provide here but please let me know if you need to see any other parts of the code. I would be extremely grateful for any suggestions of things to examine in the code or logs to get a better clue as to why this is failing.

Many thanks in advance.

解决方案

I think you should carefully read (or re-read) all the procedure described here. Add a comment if you need more help on this after you followed the tutorial from the scratch again.

90% of problems with this are related to: wrong sha1 signed certificate, wrong app package name, missing client ID and something like those...

PS: here you can find all the working samples

这篇关于Google Play游戏服务未能登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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