1
votes

I’ve had this problem for a while, and it’s increasing with increasing downloads.

It occurs in showActivityResultError() which brings up an error dialogue for connection issues to Google’s Play Game Services. I tested the default case (“No meaningful Activity response code, so generate default Google Play services dialog”) and that works Ok on my phone.

One thing – both GooglePlayServicesUtil.isGooglePlayServicesAvailable and GooglePlayServicesUtil.getErrorDialog are showing to be depreciated, but I can’t find any updates – does everyone use BaseGameUtils for their Leaderboards/Achievements anyway?

Occurs on Android versions 4.2/4.4/5.0/5.1/6.0 so no real clues there.

Top devices: Galaxy Note4 (tre3g) / Galaxy Grand Neo Plus (grandneove3g) / Galaxy Note3 (ha3g) / Galaxy J7(2016) (j7xelte) / Galaxy Tab4 7.0 (degaswifiue) / Galaxy Note4 (trlte) / Galaxy Grand Prime (grandprimeve3g) / Galaxy S6 Edge (zerolte)

The sourcecode for BaseGameUtils can be viewed here: https://github.com/playgameservices/android-basic-samples/blob/master/BasicSamples/libraries/BaseGameUtils/src/main/java/com/google/example/games/basegameutils/BaseGameUtils.java

Cheers!

java.lang.RuntimeException: 
  at android.app.ActivityThread.deliverResults(ActivityThread.java:4019)
  at android.app.ActivityThread.handleSendResult(ActivityThread.java:4062)
  at android.app.ActivityThread.access$1400(ActivityThread.java:177)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1483)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:135)
  at android.app.ActivityThread.main(ActivityThread.java:5930)
  at java.lang.reflect.Method.invoke(Method.java:0)
  at java.lang.reflect.Method.invoke(Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1405)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: android.view.WindowManager$BadTokenException: 
  at android.view.ViewRootImpl.setView(ViewRootImpl.java:574)
  at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:282)
  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
  at android.app.Dialog.show(Dialog.java:298)
  at com.google.example.games.basegameutils.BaseGameUtils.showActivityResultError(BaseGameUtils.java:154)
  at <my game here>
1
Based from this ralated SO post, you can use GoogleApiAvailability for isGooglePlayServicesAvailable and getErrorDialog. AFAIK, you should use games package for achievements and leaderboard. Hope this helps.Mr.Rebot
Thanks, I'll try making those changes and see how it goes. The crash is relatively rare WRT the number of daily sessions, but persistent.CamS

1 Answers

0
votes

I finally found the answer, and it's a very simple fix. It's actually to do with calling Dialog.show() while the Activity is in the process of finishing. It’s described well here: http://dimitar.me/android-displaying-dialogs-from-background-threads/

The fix is simply putting if(!activity.isFinishing()) before calling Dialog.show();

In my case, it’s before errorDialog.show(); in method showActivityResultError() in BaseGameUtils.java

Thant’s it. A couple of exceptions a week have disappeared.