这可能是重复但我已经尝试了互联网上的所有内容来解决这个问题但到目前为止没有运气,所以再问一遍。 我已经在libGDX中实现了一个游戏,现在使用谷歌玩游戏,使用BaseGameUtils lib和google api方法。但是当我现在开始游戏时,我会得到以下错误
未能登录。请检查您的网络连接广告再次尝试,谷歌玩游戏服务
我已检查过以下链接中提供的所有解决方案,但没有任何效果
Failed to sign in. Please check your network connection and try again
我也阅读过相同的故障排除指南,但仍然没有运气。
以下是我的AndroidManifext.xml
<?xml version="1.0" encoding="utf-8"?>
package="com.versionpb.game"
android:versionCode="10"
android:versionName="1.6" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-sdk tools:overrideLibrary="
com.google.android.gms.ads,
com.google.android.gms.ads.impl,
com.google.android.gms,
android.support.v4,
android.support.compat,
android.support.mediacompat,
android.support.coreutils,
android.support.coreui,
android.support.fragment,
com.google.android.gms.admob.license ,
com.google.android.gms.common.license,
com.google.android.gms.gass,
com.google.android.gms.gass.license,
com.google.android.gms.admob.impl.license,
com.google.example.games.basegameutils,
com.google.android.gms.games,
com.google.android.gms.games.license,
com.google.android.gms.base,
com.google.android.gms.base.license,
com.google.android.gms.tasks,
com.google.android.gms.tasks.license,
com.google.android.gms.drive,
com.google.android.gms.drive.license,
com.google.android.gms.plus,
com.google.android.gms.plus.license,
com.google.android.gms.auth,
com.google.android.gms.auth.license,
com.google.android.gms.auth.api,
com.google.android.gms.auth.api.phone,
com.google.android.gms.auth.api.phone.license
" />
<application
android:allowBackup="true"
android:icon="@mipmap/briskybirdicon"
android:label="@string/app_name"
android:theme="@style/GdxTheme">
<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
android:name="com.versionpb.game.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
这是我的Strings.xml文件
<?xml version="1.0" encoding="utf-8"?>
<string name="app_name">BriskyBird</string>
<!--
Google Play game services IDs.
Save this file as res/values/games-ids.xml in your project.
-->
<!-- package_name -->
<string name="package_name" translatable="false">com.versionpb.game</string>
</resources>
以下是我的ids.xl
<?xml version="1.0" encoding="utf-8"?>
<resources><!-- app_id -->
<string name="app_id" translatable="false">351XXXX97012</string>
<!-- leaderboard High Score Easy -->
<string name="leaderboard_high_score_easy"
translatable="false">CgkItNrXiJXXXXXXXX</string>
我使用了github repo下面的baseGameUtils
https://github.com/ahmetdenizyilmaz/connect
以下是我在核心项目中创建的界面
package com.versionpb.game;
public interface PlayServices
{
public void signIn();
public void signOut();
public void rateGame();
public void unlockAchievement(String str);
public void submitScore(int highScore);
public void submitLevel(int highLevel);
public void showAchievement();
public void showScore();
public void showLevel();
public boolean isSignedIn();
}
以下是我在AndroidLauncher中实现它的方法
package com.versionpb.game;
公共类AndroidLauncher扩展AndroidApplication实现PlayServices { private static final String TAG =&#34; AndroidLauncher&#34 ;;
private GameHelper gameHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
gameHelper.enableDebugLog(true);
GameHelper.GameHelperListener gameHelperListener = new GameHelper.GameHelperListener() {
@Override
public void onSignInFailed() {
}
@Override
public void onSignInSucceeded() {
}
};
RelativeLayout layout = new RelativeLayout(this);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
View gameView = initializeForView(new BriskyBird(this), config);
layout.addView(gameView);
setContentView(layout);
gameHelper.setup(gameHelperListener);
}
@Override
protected void onStart() {
super.onStart();
gameHelper.onStart(this);
}
@Override
protected void onStop() {
super.onStop();
gameHelper.onStop();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
gameHelper.onActivityResult(requestCode, resultCode, data);
}
@Override
public void signIn() {
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
System.out.println("PlayServices:Signin In");
gameHelper.beginUserInitiatedSignIn();
}
});
} catch (Exception e) {
System.out.println("PlayServices:Signin in Failed");
//Gdx.app.log("MainActivity", "Log in failed: " + e.getMessage() + ".");
}
}
@Override
public void signOut() {
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
System.out.println("PlayServices:Signin Out");
gameHelper.signOut();
}
});
} catch (Exception e) {
//Gdx.app.log("MainActivity", "Log out failed: " + e.getMessage() + ".");
}
}
@Override
public void rateGame() {
String str = "Your PlayStore Link";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
}
@Override
public void unlockAchievement(String str) {
Games.Achievements.unlock(gameHelper.getApiClient(), str);
}
@Override
public void showAchievement() {
if (isSignedIn()) {
startActivityForResult(Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 1);
} else {
signIn();
}
}
}
@Override
public boolean isSignedIn() {
return gameHelper.isSignedIn();
}
}
使用GameHelper过滤时的Log Cat片段
04-05 19:22:48.405 15038-15038/? D/GameHelper: GameHelper: Debug log enabled.
04-05 19:22:50.215 15038-15038/? D/GameHelper: GameHelper: Setup: requested clients: 1
04-05 19:22:50.490 15038-15038/? D/GameHelper: GameHelper: onStart :
04-05 19:22:50.490 15038-15038/? D/GameHelper: GameHelper: Connecting
客户端。 04-05 19:22:54.335 15038-15038 /? D / GameHelper:GameHelper:onConnectionFailed 04-05 19:22:54.350 15038-15038 /? D / GameHelper:GameHelper:连接失败: 04-05 19:22:54.400 15038-15038 /? D / GameHelper:GameHelper: - 代码:SIGN_IN_REQUIRED(4) 04-05 19:22:54.400 15038-15038 /? D / GameHelper:GameHelper: - resolvable:true 04-05 19:22:54.405 15038-15038 /? D / GameHelper:GameHelper: - details:ConnectionResult {statusCode = SIGN_IN_REQUIRED,resolution = PendingIntent {427a9400:android.os.BinderProxy@427b0338},message = null} 04-05 19:22:54.410 15038-15038 /? D / GameHelper:GameHelper:onConnectionFailed:将解析,因为我们已经低于最大尝试次数,0&lt; 3 04-05 19:22:54.410 15038-15038 /? D / GameHelper:GameHelper:onConnectionFailed:解决问题...... 04-05 19:22:54.410 15038-15038 /? D / GameHelper:GameHelper:resolveConnectionResult:尝试解析结果:ConnectionResult {statusCode = SIGN_IN_REQUIRED,resolution = PendingIntent {427a9400:android.os.BinderProxy@427b0338},message = null} 04-05 19:22:54.415 15038-15038 /? D / GameHelper:GameHelper:结果有分辨率。开始吧 04-05 19:23:06.675 15038-15038 /? D / GameHelper:GameHelper:onActivityResult:req = RC_RESOLVE,resp = SIGN_IN_FAILED 04-05 19:23:06.675 15038-15038 /? D / GameHelper:GameHelper:onAR:responseCode = SIGN_IN_FAILED,所以放弃了。 04-05 19:23:07.090 15038-15038 /? W / GameHelper:当客户端已经断开连接时调用disconnect()。 04-05 19:23:07.785 15038-15038 /? D / GameHelper:GameHelper:通知LISTENER登录失败(错误) 04-05 19:23:46.095 15038-15038 /? D / GameHelper:GameHelper:onStop 04-05 19:23:46.100 15038-15038 /? D / GameHelper:GameHelper:当我们登上停止时客户端已经断开连接。
错误的错误OAuth2 id
04-05 19:22:53.700 6982-6982/? I/Choreographer: Skipped 132 frames! The application may be doing too much work on its main thread.
04-05 19:22:53.725 15233-15233/? E/SELinux: Function: selinux_android_load_priority [0], There is no sepolicy file
04-05 19:22:53.725 15233-15233/? E/SELinux: Function: selinux_android_load_priority [1], There is no sepolicy version file
04-05 19:22:53.725 15233-15233/? E/SELinux: Function: selinux_android_load_priority , loading version is VE=SEPF_GT-I9300_4.3_0016
04-05 19:22:53.725 15233-15233/? E/SELinux: selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
04-05 19:22:53.795 6982-14330/? I/EventLogSendingHelper: Sending log events.
04-05 19:22:53.845 2639-2639/? D/STATUSBAR-NetworkController: refreshSignalCluster: data=-1 bt=false
04-05 19:22:53.865 2335-3296/? D/SSRMv2:Monitor: SIOP:: AP = 310 (read only)
04-05 19:22:53.865 18805-28587/? W/Auth: [GetToken] GetToken failed with status code: UNREGISTERED_ON_API_CONSOLE
04-05 19:22:53.865 2639-2639/? D/STATUSBAR-IconMerger: checkOverflow(384), More:false, Req:false Child:2
04-05 19:22:53.875 26275-10131/? E/TokenRequestor: You have wrong OAuth2 related configurations, please check. Detailed error: UNREGISTERED_ON_API_CONSOLE
04-05 19:22:54.095 2335-2751/? I/ActivityManager: Process com.samsung.android.app.watchmanagerstub (pid 15158) (adj 13) has died.
04-05 19:22:54.100 2335-2829/? I/ActivityManager: Process com.sec.smartcard.pinservice (pid 15180) (adj 11) has died.
04-05 19:22:54.110 2335-2335/? I/ActivityManager: Process com.google.android.gsf.login (pid 15198) (adj 9) has died.
04-05 19:22:54.215 2335-2478/? W/LicenseLogService: log() is called by non admin
04-05 19:22:54.290 15038-15039/? D/dalvikvm: GC_CONCURRENT freed 433K, 15% free 10331K/12048K, paused 19ms+13ms, total 133ms
04-05 19:22:54.335 15038-15038/? D/GameHelper: GameHelper: onConnectionFailed `
但我多次检查SHA1 Key是否正确,是我游戏的API中的一个,还是游戏服务中的一个。
任何线索可能出错?
以下是我用于在游戏服务中创建游戏的步骤
我有什么问题吗?我怀疑也许我错过了一些步骤,比如使用keytool生成发布证书
keytool -list -keystore
这些步骤在googles文档中设置了播放gae服务,在我的情况下,它向我展示了正确的SHA1证书,所以我没有执行此命令。
我做错了什么。任何线索
现在我尝试使用keytool -list -keystore
我获得的SHA1与在Play商店上传的内容不同。
使用哪种SHA1灵魂。一个在播放控制台和授权我的应用程序显示或生成这个?
提前致谢
答案 0 :(得分:0)
实际上因为我使用的apk是在Play商店上传的apk,但我正在测试我的笔记本电脑上的apk,所以我真的需要我使用我的密钥库获取SHA 1然后创建在链接应用程序中为应用程序创建新的OAuth2客户端ID,同样我为调试证书创建了另一个客户端。在这些变化之后,我能够登录。以下是修复此问题的步骤,我希望将来可能对其他人有所帮助。
再次尝试使用哪个代码,这次登录