SDKBOX Play C++: NullPointerException after submitScore()

How to reproduce it:

  • Sign into Google Play
  • turn off internet connection
  • submit score

My code:

if (sdkbox::PluginSdkboxPlay::isConnected())
    sdkbox::PluginSdkboxPlay::submitScore(leaderboardKey.c_str(), score);

Works correct if there is internet connection. But when the connection is gone, there is NullPointerException error and app crushes:

E/AndroidRuntime(30029): java.lang.NullPointerException: Attempt to read from field ‘boolean com.google.android.gms.games.leaderboard.ScoreSubmissionData$Result.newBest’ on a null object reference
E/AndroidRuntime(30029): at com.sdkbox.plugin.PluginSdkboxPlay$1.onResult(Unknown Source)
E/AndroidRuntime(30029): at com.sdkbox.plugin.PluginSdkboxPlay$1.onResult(Unknown Source)
E/AndroidRuntime(30029): at com.google.android.gms.internal.zzly$zza.handleMessage(Unknown Source)
E/AndroidRuntime(30029): at android.os.Handler.dispatchMessage(Handler.java)
E/AndroidRuntime(30029): at android.os.Looper.loop(Looper.java)
E/AndroidRuntime(30029): at android.app.ActivityThread.main(ActivityThread.java)
E/AndroidRuntime(30029): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(30029): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(30029): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
E/AndroidRuntime(30029): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)

I’m not using listeners.

Cocos2d-x v3.10, SDKBOX Play v2.2.1.7

I was not able to reproduce the issue: I launch SDKBOX Play CPP sample APP > sign into Google Play > Dis-connect Internet connection > Google play popup and ask for sign-in > click submit score does not trigger exception.
What is the version of your SDKBOX Play and could you try update the plug-in?

SDKBOX Play v2.2.1.7. Updated before posting from v2.2.1.6 (same error).

Sample app uses listeners. I don’t want to use them (and I don’t need them). So it looks like the problem is in default listener.

I have tested with and without plugin listeners. Also, with and without internet connection. and 2.2.2 seems to be fine.

GPS seems to buffer the leaderboard call to a later time in case there’s no connection available so there should be no problem either.

I have gone one step beyond, and tested on 2.2.1.x. In the case there was no apiClient, for example, when the apk was not signed, or was signed with a different certificate than the one supplied in the google play console, a score submission made the app crash. But never got it to crash in the described use case.

Please test 2.2.2 and let us know if it sill crashes for you.
Thanks.

Where can I get 2.2.2? I would like to try it, but updater shows 2.2.1.7 as latest version.

My app is published in google play in closed alpha test mode. Everything works fine when there is internet connection: scores are uploaded, leaderboards are displayed, etc. When the connection is gone, leaderboard intent is shown with “sad cloud” (correct), but when the level ends and the score is buffered by google games, the app crashes and in logcat there is exception: reading bool value newBest from empty object (please see my first post for details). I don’t register listener for sdkboxplay, so it has to be something internal in sdkbox.

I’ll add sdkboxplay listener tomorrow and I’ll check if it helps.

Edit: @nite It looks similar to error with facebook plugin from other thread

ok we’re still trying to reproduce this issue, we did fix a crash issue for facebook when there in no internet connection, we’ll release 2.2.2 soon with the fix.

It looks like in 2.2.2.10 the problem is fixed. Hurray :smiley: You are great! Thanks guys!