Development Google HTTP

Games APIs requires function

Trying to get Google Play Games services working using Kotlin (there seems to be no info available, even from Google unless you use Java!). I’ve got the sign in working last night and set up some achievements, tonight the first test I’m trying to do is display achievements or a leaderboard but the app just closes with this error:

java.lang.IllegalStateException: Games APIs requires function.

To log users in, I use:

val RC_SIGN_IN = 9001
var gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) // have also tried DEFAULT_GAMES_SIGN_IN
var mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
var GoogleSignInAccount = GoogleSignIn.getLastSignedInAccount(this)
val signInIntent = mGoogleSignInClient.getSignInIntent()
startActivityForResult(signInIntent, RC_SIGN_IN)

Then to view, for example, leaderboard, I use:

Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this)!!)
    .getLeaderboardIntent(getString(R.string.leaderboard_leaders)) // leaderboard_leaders is the leaderboard name
      .addOnSuccessListener { intent -> startActivityForResult(intent, RC_LEADERBOARD_UI) }

I have tried the answers on SO, which all seem to be to add .requestScopes(Games.SCOPE_GAMES_LITE) or change DEFAULT_SIGN_IN to DEFAULT_GAMES_SIGN_IN, but these don’t work, if I add either of these then it doesn’t sign the user in at all. Any help appreciated

Leave a Reply

Your email address will not be published. Required fields are marked *