This question has been asked multiple times, yet no answer have worked for me.
Here's some insight :
I am using BaseGameUtils
In my logs I am getting
You have wrong OAuth2 related configurations, please check. Detailed error: UNREGISTERED_ON_API_CONSOLEIn my manifest file I have inside the application item I have
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id"I have added my email as a tester account
The game is a draft on the google console API
I have added
INTERNETANDACCESS_NETWORK_STATEpermissionsI have generated credentials using keytool on the debug.keystore file and copied to SHA-1 result to credentials in the Google Console API
I have deleted debug.keystore to regenerate a SHA-1 key as shown here
My manifest file looks like this :
<?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>
The implementation looks like this :
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();
}
}