Error if app is disposed before purchasemanager install ends
Trurl101 opened this issue · 2 comments
I just included gdx-pay-12-SNAPSHOT in some of my games and got a few errors like this:
java.lang.NullPointerException:
at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling.fetchOfferDetails (PurchaseManagerGoogleBilling.java:111)
at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling.access$100 (PurchaseManagerGoogleBilling.java:42)
at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling$1.run (PurchaseManagerGoogleBilling.java:83)
at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling$2.onBillingSetupFinished (PurchaseManagerGoogleBilling.java:99)
at com.android.billingclient.api.BillingClientImpl$BillingServiceConnection.onServiceConnected (BillingClientImpl.java:903)
at android.app.LoadedApk$ServiceDispatcher.doConnected (LoadedApk.java:1335)
at android.app.LoadedApk$ServiceDispatcher$RunConnection.run (LoadedApk.java:1352)
at android.os.Handler.handleCallback (Handler.java:739)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:158)
at android.app.ActivityThread.main (ActivityThread.java:7224)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
It seems when the App is exited (and purchasemanager disposed) before the purchasemanager finished installing it causes a crash.
I can reproduce the same crash if I just exit the app shortly after calling the purchasemanager install like:
purchaseManager.install(purchaseObserver, purchaseManagerConfig, true);
Gdx.app.exit();
The apps dispose method includes this of course:
if (purchaseManager != null) {
purchaseManager.dispose();
}
As I understand the problem is the "service connection" that starts in PurchaseManagerGoogleBilling on line 77: startServiceConnection(new Runnable() {...
it will call fetchOfferDetails()
even if the manager is disposed and then in line 111 int offerSize = config.getOfferCount()
the config is already gone and causes the nullpointer exception.
Thank you for the stack trace, I also think your assumption applies. Please check the latest snapshot I just pushed and the changes I did today and yesterday, this should fix the problem.
Fixed in 0.12.0