Bug fix bounty: reward £40 (GPS in game)

andymc

Well-Known Member
Licensed User
Longtime User
My game Invaders has a bug, when launching the game, if you open google play achievements before it has fully signed in, then the game crashes. This is how I reproduce the error, but there may be other causes.

play store link: https://play.google.com/store/apps/details?id=uk.co.coffeeinducedgames.invaders


I need someone well versed in using Google Play game services with B4A to review my game code to see why it's crashing, the error messages google play console gives me for player logs are:

java.lang.NullPointerException:
at uk.co.coffeeinducedgames.invaders.main._gp_onachievementsloaded (main.java:2371)
at java.lang.reflect.Method.invoke (Native Method)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:186)
at flm.b4a.googleplay.PendingResultWrapper.RaiseEvent (PendingResultWrapper.java:230)
at flm.b4a.googleplay.PendingResultWrapper.access$0 (PendingResultWrapper.java:226)

java.lang.NullPointerException:
at flm.b4a.googleplay.LeaderboardsWrapper.SubmitScore (LeaderboardsWrapper.java:206)
at uk.co.coffeeinducedgames.invaders.main._submit_score (main.java:5396)
at java.lang.reflect.Method.invoke (Native Method)

Message me if you think you're up to the job. I'd expect someone to spend no longer than around an hour on this as the fix should involve just a few lines of code to either delay login or change how I detect login being a success. I'll send the game project zip file to anyone who thinks they can do this.

Payment will be £20 on delivery and passing my own tests, then the remaining £20 after 7 days when crash reports from users have dropped.
 
D

Deleted member 103

Guest
My game Invaders has a bug, when launching the game, if you open google play achievements before it has fully signed in, then the game crashes. This is how I reproduce the error, but there may be other causes.

I recommend to use Crashlytics because since I use this I can better find the reason for the bugs in my apps.
Crashlytics - crash reports
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Hi Andy - I think you have a couple of separate issues there. To stop the achievements (or leaderboards) intent being called before the GPGS sign-in has completed (or if the user has opted not to sign in at all), I use this code:

B4X:
   'somewhere in your code 
    If playServicesActive Then
        'Do some GPGS stuff
    Else
        'Tell the user they aren't signed in or sign them in then do GPGS stuff
    End If

    Private Sub playServicesActive() As Boolean
        If Connection.IsInitialized And Connection.IsSignedIn Then 
            Log("Play services active")
            Return True 
        Else
            Log("Play services NOT active")
            Return False
        End If
    End Sub

For the onAchievementsLoaded crash - I had the same issue for a long time & could never get to the bottom of it, so now I just don't load a list of achievements. The only use for it is to check whether an achievement has been unlocked - but you don't really need to because you can just fire off another unlock anyway if appropriate. Sure, it generates a tiny bit of network activity, but it's better than having the crash.

The .SubmitScore crash is because you tried to submit a score & either your connection or your leaderboard object is not initialized. Again, you can use the code above to check that the user is signed in - & if not sign them in & submit the score.

- Colin.
 

andymc

Well-Known Member
Licensed User
Longtime User
I think I've fixed it!
I had this:

Sub Connection_Success(Success As Byte)
Log("Connection_Success callback")
If Success = Connection.SUCCESS_SIGNIN Then
ToastMessageShow("Play Services Login Successful.", False)
'Initializes the Achievements and Leaderboards classes
Achievements.Initialize
Leaderboards.Initialize
Load_Achievements
'Submit_Score("")
else if Success = Connection.SUCCESS_SIGNOUT Then
ToastMessageShow("Play Services Logout Successful.", False)
else if Success = Connection.SUCCESS_CONNECTED Then
Log("Connection Success!")
End If

End Sub


I think thew Load_Achievements line was running before it had fully signed in to GPS. I'll comment out the line Load_Achievements to see if this helps.
 
Top