Google Play Game Service crash if when logout

Hi,

I think this is not a new problem and it was reported on below forum thread too.

https://forums.coronalabs.com/topic/38108-google-play-game-services-crash-app/

In my game, I have a button, called gamePlayButton, that load login screen or show leaderboard depending on if the user is already login or not. These are the steps to reproduce problem:

  1. touch the gamePlayButton to show login

  2. login

  3. touch the button again to show leaderboard

  4. touch the leaderboard sign to load leaderboard screen

  5. touch on the menu at the upper right corner (three dots)

  6. settings

  7. sign out

After signing out, the GPGS doesn’t close itself and if you touch on the leaderboard sign again, it will crash. We can touch the arrow at the upper left corner to close it (in this case, no crash) 

  1. In both cases above (crash or no crash), touch the gamePlayButton again, the game will crash.

But if I do the following, it will never crash.

  1. touch the gamePlayButton to show login

  2. login

  3. touch on the menu at the upper right corner (three dots)

  4. settings

  5. sign out

The GSPS close itself and if I touch the gamePlayButton again, it will show the login screen again without any problem. I can repeat this steps and it will never crash.

And this is my code and I’m using build 2646.

main.lua

local gameNetwork = require "gameNetwork" gameNetwork.init("google") local leaderboardId = "XXXXXXX....." gameNetwork.request("login", { userInitiated = false }) local function gameNetworkRequest(event) if event.phase == "ended" then local function loginListener(event1) if event1.isError then --if error else --if no error end end if gameNetwork.request("isConnected") then gameNetwork.show("leaderboards") else gameNetwork.request("login", { userInitiated = true, listener = loginListener }) end end end gamePlayButton:addEventListener("touch", gameNetworkRequest)

build.settings

settings = { orientation = { default = "portrait", supported = { "portrait", "portraitUpsideDown" }, }, android = { usesPermissions = { "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "com.android.vending.CHECK\_LICENSE", "com.android.vending.BILLING", }, googlePlayGamesAppId = "XXXXXXXX...." }, plugins = { ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", supportedPlatforms = { android = true }, }, }, }

I also test above steps with two other games (one is known to be made with Corona) and the result is the same. So I’m not sure if it is Google or Corona problem. I hope to find solution or at lease a way to handle the crash here.

Thank you.

So Lin

I think its Google problem but some games are able to prevent crashing at their UI (compared to my case, their game wouldn’t crash when touch on the button again after signing out from leaderboard).I wonder how could we handle that with Corona.

So Lin

Anyone? Corona staff?

Hi So Lin,

I’ve been able to look into your issue and am in agreement that this is a Google problem. Here’s more specifics:

I could only reproduce the issue you mentioned on devices running Android 5.1. On Android 5.0 and 4.4, Google Play Services closed as expected.

On top of your code snippet above, we were able to reproduce the issue with our Leaderboards and Achievements sample.

Lastly, we tested this with two Unity-made games (Lara Croft: Relic Run and Crossy Road), and those also caused Google Play Games to crash in the same way.

Here’s the exception that’s thrown in all the aforementioned tests:

E/AndroidRuntime(12238): FATAL EXCEPTION: main

E/AndroidRuntime(12238): Process: com.google.android.play.games.ui, PID: 12238

E/AndroidRuntime(12238): java.lang.SecurityException: Not signed in when calling API

E/AndroidRuntime(12238): at android.os.Parcel.readException(Parcel.java:1546)

E/AndroidRuntime(12238): at android.os.Parcel.readException(Parcel.java:1499)

E/AndroidRuntime(12238): at com.google.android.gms.games.internal.IGamesService$Stub$Proxy.getLeaderboardIntentV2(IGamesService.java:6576)

E/AndroidRuntime(12238): at com.google.android.gms.games.internal.GamesClientImpl.getLeaderboardIntent$2e1cfbaf(GamesClientImpl.java:3503)

E/AndroidRuntime(12238): at com.google.android.gms.games.internal.api.LeaderboardsImpl.getLeaderboardIntentInternal(LeaderboardsImpl.java:294)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.client.leaderboards.ClientLeaderboardFragment.showLeaderboardScoreUi(ClientLeaderboardFragment.java:34)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.common.leaderboards.LeaderboardFragment.onLeaderboardClicked(LeaderboardFragment.java:102)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.common.leaderboards.LeaderboardAdapter$LeaderboardViewHolder.onRootViewClicked(LeaderboardAdapter.java:83)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.card.OnyxBaseCardView.onClick(OnyxBaseCardView.java:373)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.card.OnyxSmallCardView.onClick(OnyxSmallCardView.java:353)

E/AndroidRuntime(12238): at android.view.View.performClick(View.java:4780)

E/AndroidRuntime(12238): at android.view.View$PerformClick.run(View.java:19866)

E/AndroidRuntime(12238): at android.os.Handler.handleCallback(Handler.java:739)

E/AndroidRuntime(12238): at android.os.Handler.dispatchMessage(Handler.java:95)

E/AndroidRuntime(12238): at android.os.Looper.loop(Looper.java:135)

E/AndroidRuntime(12238): at android.app.ActivityThread.main(ActivityThread.java:5254)

E/AndroidRuntime(12238): at java.lang.reflect.Method.invoke(Native Method)

E/AndroidRuntime(12238): at java.lang.reflect.Method.invoke(Method.java:372)

E/AndroidRuntime(12238): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

E/AndroidRuntime(12238): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Hi,

I have two devices with 4.4 (Samsung and huawei) and both have the same issue. Did you touch on the leaderboard sign and stay there when you sign out?

Other games have the same issue but they can prevent crashing from happening when interacting with their UI (tap login button or leaderboard button). How can we archieve that? I mean if error happen, we keep the game silent or suppress error rather than letting the app crash. You can try a game called Give It Up, it is able to deal with this google problem by not generating any error message and after playing a few more time (without the need to close the game) we will be able to login to GPGS again.

Thank you.
So Lin

Hi Ajay,

I forgot to tell one thing. After signing out (with that long steps), if we play the game and post high score the game will crash with error message java.lang.SecurityException: Not signed in when calling API. How can we handle that?

Thanks,
So Lin

I try suppress the error with below code but still the error message pop up and the game crash. The code is at the beginning of the file.

local function myUnhandledErrorListener( event ) return true end Runtime:addEventListener("unhandledError", myUnhandledErrorListener)

There should be a way to handle this case otherwise games developed with Corona are left with crash when GPGS is implemented.

So Lin

Even though it is Google problem, it is affecting the game in overall. I hope we have a way to suppress the error just as this game https://play.google.com/store/apps/details?id=com.invictus.impossiball and https://play.google.com/store/apps/details?id=com.bengigi.noogranuts does.

Thank you.

So Lin

We did some further testing and found that the second case you had mentioned (using the arrow to exit the leaderboard screen that should’ve disappeared, and then hitting the gamePlayButton again), does cause Corona to crash. We saw similar behavior in the aforementioned Unity games, but the source of the crash is different.

For this case, we are working on a fix.

Hi Ajay,

Thank you for looking into this and working on a fix. To add more info, if we don’t touch gamePlayButton but play the game and post high score, the game will crash too and pop up Runtime error message I reported in my previous post.

I’m delaying my game update for now because of this problem and I hope we’ll have a fix for this soon.

Thank you.
So Lin

Hi Ajay,

May I know when I can expect the fix? Thank you.

So Lin

Hi Ajay,

Any update on this?

Thanks,

So Lin

It seems that Google has fixed their bug.

So Lin

I think its Google problem but some games are able to prevent crashing at their UI (compared to my case, their game wouldn’t crash when touch on the button again after signing out from leaderboard).I wonder how could we handle that with Corona.

So Lin

Anyone? Corona staff?

Hi So Lin,

I’ve been able to look into your issue and am in agreement that this is a Google problem. Here’s more specifics:

I could only reproduce the issue you mentioned on devices running Android 5.1. On Android 5.0 and 4.4, Google Play Services closed as expected.

On top of your code snippet above, we were able to reproduce the issue with our Leaderboards and Achievements sample.

Lastly, we tested this with two Unity-made games (Lara Croft: Relic Run and Crossy Road), and those also caused Google Play Games to crash in the same way.

Here’s the exception that’s thrown in all the aforementioned tests:

E/AndroidRuntime(12238): FATAL EXCEPTION: main

E/AndroidRuntime(12238): Process: com.google.android.play.games.ui, PID: 12238

E/AndroidRuntime(12238): java.lang.SecurityException: Not signed in when calling API

E/AndroidRuntime(12238): at android.os.Parcel.readException(Parcel.java:1546)

E/AndroidRuntime(12238): at android.os.Parcel.readException(Parcel.java:1499)

E/AndroidRuntime(12238): at com.google.android.gms.games.internal.IGamesService$Stub$Proxy.getLeaderboardIntentV2(IGamesService.java:6576)

E/AndroidRuntime(12238): at com.google.android.gms.games.internal.GamesClientImpl.getLeaderboardIntent$2e1cfbaf(GamesClientImpl.java:3503)

E/AndroidRuntime(12238): at com.google.android.gms.games.internal.api.LeaderboardsImpl.getLeaderboardIntentInternal(LeaderboardsImpl.java:294)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.client.leaderboards.ClientLeaderboardFragment.showLeaderboardScoreUi(ClientLeaderboardFragment.java:34)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.common.leaderboards.LeaderboardFragment.onLeaderboardClicked(LeaderboardFragment.java:102)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.common.leaderboards.LeaderboardAdapter$LeaderboardViewHolder.onRootViewClicked(LeaderboardAdapter.java:83)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.card.OnyxBaseCardView.onClick(OnyxBaseCardView.java:373)

E/AndroidRuntime(12238): at com.google.android.gms.games.ui.card.OnyxSmallCardView.onClick(OnyxSmallCardView.java:353)

E/AndroidRuntime(12238): at android.view.View.performClick(View.java:4780)

E/AndroidRuntime(12238): at android.view.View$PerformClick.run(View.java:19866)

E/AndroidRuntime(12238): at android.os.Handler.handleCallback(Handler.java:739)

E/AndroidRuntime(12238): at android.os.Handler.dispatchMessage(Handler.java:95)

E/AndroidRuntime(12238): at android.os.Looper.loop(Looper.java:135)

E/AndroidRuntime(12238): at android.app.ActivityThread.main(ActivityThread.java:5254)

E/AndroidRuntime(12238): at java.lang.reflect.Method.invoke(Native Method)

E/AndroidRuntime(12238): at java.lang.reflect.Method.invoke(Method.java:372)

E/AndroidRuntime(12238): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

E/AndroidRuntime(12238): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Hi,

I have two devices with 4.4 (Samsung and huawei) and both have the same issue. Did you touch on the leaderboard sign and stay there when you sign out?

Other games have the same issue but they can prevent crashing from happening when interacting with their UI (tap login button or leaderboard button). How can we archieve that? I mean if error happen, we keep the game silent or suppress error rather than letting the app crash. You can try a game called Give It Up, it is able to deal with this google problem by not generating any error message and after playing a few more time (without the need to close the game) we will be able to login to GPGS again.

Thank you.
So Lin

Hi Ajay,

I forgot to tell one thing. After signing out (with that long steps), if we play the game and post high score the game will crash with error message java.lang.SecurityException: Not signed in when calling API. How can we handle that?

Thanks,
So Lin

I try suppress the error with below code but still the error message pop up and the game crash. The code is at the beginning of the file.

local function myUnhandledErrorListener( event ) return true end Runtime:addEventListener("unhandledError", myUnhandledErrorListener)

There should be a way to handle this case otherwise games developed with Corona are left with crash when GPGS is implemented.

So Lin

Even though it is Google problem, it is affecting the game in overall. I hope we have a way to suppress the error just as this game https://play.google.com/store/apps/details?id=com.invictus.impossiball and https://play.google.com/store/apps/details?id=com.bengigi.noogranuts does.

Thank you.

So Lin