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.
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.
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
According to 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
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.
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?
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"/>
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();
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();
}
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.
Many thanks in advance.
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% of problems with this are related to: wrong sha1 signed certificate, wrong app package name, missing client ID and something like those...
PS: here you can find all the working samples