Google Play 游戏服务无法登录
这几天我一直在用头撞墙.尽管阅读了许多描述 GPS 登录失败的许多问题/解决方案的帖子,但我一直无法找到解决问题的方法.
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.
简而言之,我正在使用 LibGDX 框架在 Android Studio 中开发游戏,并将 BaseGameUtils 添加为库并添加了所有必要的依赖项等.
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.
问题说明:当游戏开始时,它会尝试连接到 GPGS,但总是以登录失败"消息作为响应.logcat 包含以下消息:
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
根据 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
我的网络不是不稳定",我不相信我的帐户已被禁用 - 我安装的其他商业游戏在 GPGS 上运行良好.
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.
我已经签署了我的 APK - 调试和发布(虽然我在这个阶段只使用调试).我已将游戏添加到 Google Developer Console 中,并将其链接到 API Manager 并创建了 OAuth2 客户端 ID.事实上,我已经这样做了很多次,删除链接的游戏并重新创建它认为我的客户端 ID 或 SHA1 指纹不正确.logcat 消息表明 OAuth2 配置错误,但我已经检查了很多次,对我来说一切正常.验证签名的最佳方法是什么?
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?
我正在直接从我的笔记本电脑部署到的物理三星 S7 上进行测试.我的 Android Gradle 声明了必要的 SigningConfigs,因此我相信我部署的游戏应该正确签名.
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"/>
最初,在 AndroidLauncher 中,我使用的是 GameHelper 类,但最近发现它已被弃用,因此我将代码更改为使用 GoogleApiClient.构建器定义如下:
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();
其他方法的代码直接取自 TrivialQuest 示例应用程序,例如-
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();
}
但是,尽管使用了 Google API 客户端代码,但这并没有什么不同.
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.
非常感谢.
推荐答案
我认为你应该仔细阅读(或重新阅读)描述的所有过程 这里.如果您在从头开始学习本教程后需要更多帮助,请添加评论.
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% 的问题与以下问题有关:错误的 sha1 签名证书、错误的应用程序包名称、缺少客户端 ID 等等......
90% of problems with this are related to: wrong sha1 signed certificate, wrong app package name, missing client ID and something like those...
PS:这里你可以找到所有的工作样品
PS: here you can find all the working samples
相关文章