这个问题已被多次询问,但没有答案对我有用。
以下是一些见解:
我正在使用BaseGameUtils
在我的日志中,我收到You have wrong OAuth2 related configurations, please check. Detailed error: UNREGISTERED_ON_API_CONSOLE
在我的清单文件中,我有应用程序项目<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id"
我已将我的电子邮件添加为测试人员帐户
该游戏是Google控制台API的草稿
我添加了INTERNET
和ACCESS_NETWORK_STATE
权限
我已使用keytool在debug.keystore文件上生成凭据,并将其复制到SHA-1结果中,以及Google控制台API中的凭据
我已删除debug.keystore以重新生成SHA-1密钥,如图所示here
我的清单文件如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.martenscedric.hexpert"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
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" />
<activity
android:name="com.martenscedric.hexpert.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="landscape"
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>
</manifest>
实现如下:
private GameHelper gameHelper;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
gameHelper.enableDebugLog(false);
GameHelper.GameHelperListener gameHelperListener = new GameHelper.GameHelperListener() {
@Override
public void onSignInFailed() {
}
@Override
public void onSignInSucceeded() {
}
};
gameHelper.setup(gameHelperListener);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new Hexpert(this), config);
}
@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() {
gameHelper.beginUserInitiatedSignIn();
}
});
}catch (Exception e)
{
e.printStackTrace();
}
}
@Override
public void signOut() {
try
{
runOnUiThread(new Runnable() {
@Override
public void run() {
gameHelper.signOut();
}
});
}catch (Exception e)
{
e.printStackTrace();
}
}
答案 0 :(得分:0)
原来这是一个重构问题。当我将项目的名称从A重构为B时,我确实将清单更改为com.me.B,但不是在Gradle中。