Crashing during unlocking achievement

0

Once the updateAchievement(int percentage) function is called the game crashes as below

The game crashes with

Fatal signal 11 (SIGSEGV) at 0x00000088 (code=1), thread 6584 (Thread-6615)

at

static public void updateAchievement(int percentage)
{
  if(gpgAvailable){
    Games.Achievements.unlock(((RampJump)currentContext).getGameHelper().getApiClient(), achievementIDs[currentAchievementID]);
  }
}

The achievements gets unlocked but the game crashes immediately. I am struck with this error for a long time. Please help regarding it. Thanks in advance.

android
cocos2d-x
google-play-games
asked on Stack Overflow Dec 12, 2014 by (unknown user) • edited Dec 12, 2014 by Hacketo

1 Answer

0

Where do you initialize your Google API client? Personally, to unlock an achievement I use this:

public void unlockAchievement(int id)
{
    Games.Achievements.unlock(mGoogleApiClient, AchievementIDs[id]);
}

"mGoogleApiClient" is initialized in OnCreate like so:

    mGoogleApiClient = new GoogleApiClient.Builder(this)
    .addConnectionCallbacks(this)
    .addOnConnectionFailedListener(this)
    .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
    .addApi(Games.API).addScope(Games.SCOPE_GAMES)
    .addApi(Drive.API).addScope(Drive.SCOPE_APPFOLDER)
.build();

I hope this helps :)

answered on Stack Overflow Dec 17, 2014 by Scumble373

User contributions licensed under CC BY-SA 3.0