1

This might be a duplicate but i have tried everything available on internet to fix this but no luck so far , so asking again . I have implemented a game in libGDX and now using google play games in it , using BaseGameUtils lib and google api methods . but when i start game now i get below error

failed to sign in . Please check your network connection ad try again , google play game services

I have checked for all solutions provided in the below link but nothing worked

Failed to sign in. Please check your network connection and try again

I have also read troubleshooting guide on the same but still no luck .

Below is my 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>

Here is my Strings.xml file

<?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>

Below is my 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>

I have used baseGameUtils from below github repo

https://github.com/ahmetdenizyilmaz/connect

Below is my interface i have created in core project

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();
}

Below is how I have implemented it in the AndroidLauncher

package com.versionpb.game;

public class AndroidLauncher extends AndroidApplication implements PlayServices { private static final String TAG = "AndroidLauncher";

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();
}

}

Log Cat snippet when i filter with GameHelper

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 

client. 04-05 19:22:54.335 15038-15038/? D/GameHelper: GameHelper: onConnectionFailed 04-05 19:22:54.350 15038-15038/? D/GameHelper: GameHelper: Connection failure: 04-05 19:22:54.400 15038-15038/? D/GameHelper: GameHelper: - code: 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: WILL resolve because we have below the max# of attempts, 0 < 3 04-05 19:22:54.410 15038-15038/? D/GameHelper: GameHelper: onConnectionFailed: resolving problem... 04-05 19:22:54.410 15038-15038/? D/GameHelper: GameHelper: resolveConnectionResult: trying to resolve result: 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: Result has resolution. Starting it. 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, so giving up. 04-05 19:23:07.090 15038-15038/? W/GameHelper: disconnect() called when client was already disconnected. 04-05 19:23:07.785 15038-15038/? D/GameHelper: GameHelper: Notifying LISTENER of sign-in FAILURE (error) 04-05 19:23:46.095 15038-15038/? D/GameHelper: GameHelper: onStop 04-05 19:23:46.100 15038-15038/? D/GameHelper: GameHelper: Client already disconnected when we got onStop.

Errors which says wrong 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 `

But i ave checked many times the SHA1 Key is correct , the one in the API of my game and one in the play game services .

Any Clue what could be wrong ?

Below are the steps I used to create the game in play services

  1. I have version 1.6 up and live for my game uploaded in PLay COnsole
  2. Open Console --> Game Services --> Add a New game
  3. used Tab I don't use any Google APIs in my game yet
  4. Entered all game detils etc and saved game
  5. Clicked create a linked application
  6. Clicked on package Name and it showed me my game so i selected the game/correct package name
  7. didnt select realtime multiplayer or anti piracy etc option
  8. Clicked Save Clicked on Authorize your app
  9. Now here it shows me my game package name and SHA1 certificate which is again there in the game SHA 1 package which is uploaded , when i click on confirm it says linked successfuly and shows me a OAuth2 Client ID and applicaiton id
  10. I add leaderboard : just game leaderoard name as of now and clicked save .
  11. publishing and click publish game and its published
  12. Now go to Leaderboards and select leaderboard , clicked get resources , copy them and save in my Strings.xml of project code changes with leaderboards and related code implemented
  13. Execute this all on my phone and get error as specified above .

Is there anything i am doing wrong . I doubt maybe i have missed some steps like generating the release certificate using keytool

keytool -list -keystore

These steps are there in googles documentation of setting up play gae services , bt in my case it showed me correct SHA1 certificate so i didnt execute this command .

What is it that i am doing wrong . Any clues

?

Now i tried using keytool -list -keystore

I get a different SHA1 generated than with what is uploaded at play store .

Which SHA1 soule be used . One at the play console and the one which Authorize my app shows or this one that is generated ?

Thanks in advance

paarth batra
  • 1,392
  • 4
  • 29
  • 53

1 Answers1

0

Actually because I was using the SHA 1 of the apk which was uploaded at play store but i was testing with the apk which was on my laptop so it was really required that I should get the SHA 1 using my keystore and then create a new OAuth2 Client ID for the Application in Linked app , similarly i created another client for debug certificate . After these changes , i was able to log in . Below are steps again which fixed this issue , I hope it might help anyone else in future .

  1. Go to command prompt and do cd < path of keytool> which is usually C:\Program Files\Java\jdk1.7.0_72\bin
  2. Execute below command keytool -list -keystore should be a .jks file which you might have created while generating a apk using android studio
  3. Out put of this should be your Certificate fingerprint (SHA1): , Note it down
  4. Generate a debug Certificate as well using below command keytool -list -keystore C:\Users\USER.android\debug.keystore password for debug certificate is usually android
  5. Go to linked app and click on Link another app , I assume we already have 1 app linked , i.e. which SHA 1 of the apk which is aready at Play Store
  6. Enter your package name and click on Authorize app
  7. it will show the SHA1 of the app which is uploaded at play store but remove it and put the SHA 1 which you generated i.e. output of step 3
  8. similarly add another linked app and this time add your debug SHA 1, generated at step 4
  9. Go to game details from left menu and scroll down to section API Console project
  10. CLick on the project name in blue
  11. From left menu click on key and then credentials
  12. here now there should be 3 OAuth 2.0 client IDs , 1 of the apk uploaded at play store , 1 of your apk which you generated from your laptop using keystore , 3rd is your debug keystore

Try again which code and this time it logs in

paarth batra
  • 1,392
  • 4
  • 29
  • 53
  • This is difficult to understand. Can you explain in a diagrammatic way? 1 keystore for debug and 1 release keystore & keyalias within it, exists for now. how many more are requried, not sure my above details? and what is sha1 and what is oauth, where these are used, how they are related, very difficult to understand from above. – Manohar Reddy Poreddy Mar 19 '19 at 13:29