2
votes

I'm trying to implement a very simple leaderboard into a trivia section of an app. For the past few days I have been slamming my face into this code to no avail - no matter what I try the login screen just indefinitely loops (E.G. when I start the activity I get the "connecting to Google Play Games, it pops up with my synced Google Accounts, I choose one and then it just goes back to the activity with "connecting to Google Play Games" again". It does this no matter what the user inputs. The only error that I get is

02-27 15:24:20.735: E/dalvikvm(6467): Could not find class 'com.google.android.gms.internal.fq$b', referenced from method com.google.android.gms.internal.fq.a

And this error also only shows up the first time it tries, I get nothing if I try to log in again even if I go somewhere else on the app and come back to the trivia.

Here is my code for submitting a score to the leaderboard:

int answers;
Button subScore;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.scorescreen);

    Intent mIntent = getIntent();
    answers = mIntent.getIntExtra("answers", 0);

    subScore = (Button) findViewById(R.id.bSubScore);
    subScore.setText("" + answers + "/100");

    beginUserInitiatedSignIn();

}

@Override
public void onSignInFailed() {
    subScore.setText("FAYULED");
    // TODO Auto-generated method stub
    Log.d("GPS", "failed");

}

@Override
public void onSignInSucceeded() {
    Log.d("GPS", "succeeded");
    subScore.setText("WE COO");
    Games.Leaderboards.submitScore(getApiClient(), "laser", 12345);
    startActivityForResult(Games.Leaderboards.getLeaderboardIntent(
            getApiClient(), "CgkIvIukofYXEAIQAQ"), 5);

}

}

It never gets to signInFailed() or signInSucceeded(). I've checked the logs. I am extending the BaseGameActivity from the BaseGameUtils library project. and I have the appropriate imports.

Things that I have done to try and figure this out:

  • Made sure the BaseGameUtils is a library project
  • Made sure I have google-play-services_lib as a library project
  • Made sure BaseGameUtils has a reference to google-play-services_lib
  • Made sure my project has a reference to BaseGameUtils (I've also tried with references to both BaseGameUtils and google-play-services_lib)
  • Made sure that my Google Play Game has a valid Oath2.0 client ID, with the correct SHA1 key for my keystore
  • Made sure that I have an ids.xml file in res->values with the 12 digit number for my game's client ID and the Leaderboard ID
  • Made sure I am running the game on an actual android device logged in as the tester account
  • Made sure the tester account is explicity listed under "tester accounts" in the Google Play Developer Console.
  • Made sure that the version of the game I am running on the android device is actually the signed version with the same key mentioned above with the Oath2.0 client
  • Made sure that my game is linked to the proper application in my developer console and the package names match.
  • Made sure I have the proper meta-data tag in my manifest.xml within the tag.

<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="@string/app_id" />

any suggestions would be sincerely appreciated, I have been digging for almost a week trying to figure this out to no avail.

Thanks in advance for your time!

1
I don't know if this will work but I reckon it's worth a try. Take the beginUserInitiatedSignMethod out of the onCreate. Instead, put it in the onClick method of a listener and attach the listener to a button in the onCreate. Then tap the button in your app and see if it works. - Ogen
Same thing :/ I'm pretty sure it was originally in the onClick() of a button but I moved it to the onCreate() for the same "worth a shot" reasoning. - user3362723
Please post entire logcat as well(not just errors). Recommend moving to button as it was originally.. And showing log from that point. Were you able to run the ButtonClicker (or other Google project) successfully? - user2346305
Will post logs first thing @ work tomorrow - user3362723
@user3362723, have you resolved the problem? I am having the same issue. - LA_

1 Answers

1
votes

This looks like your code is probably using BaseGameActivity. This is no longer the recommended approach. I know it's a pain, but if you re-write your login logic to use GoogleApiClient directly then you will not have this problem. It only takes a few minutes.

This tutorial should walk you through the process.