You have forgot to add the BillingClient.endConnection() to the PurchaseManagerGoogleBilling.dispose() method
See original GitHub issueIn javadocs of BillingClient.java it says:
When you are done with this object, don’t forget to call endConnection() to ensure proper cleanup. This object holds a binding to the in-app billing service and the manager to handle broadcast events, which will leak unless you dispose it correctly. If you created the object inside the onCreate(Bundle) method, then the recommended place to dispose is the the onDestroy() method.
The TrivialDrive v2 sample app shows this has endConnection() too:
public void destroy() {
Log.d(TAG, "Destroying the manager.");
if (mBillingClient != null && mBillingClient.isReady()) {
mBillingClient.endConnection();
mBillingClient = null;
}
}
TrivialDrive v2 sample app BillingManager.java
I use PurchaseManager.dispose() on the Game.dispose()
In this case all good: start app-> start purchase-> cancel purchase-> home button-> start app-> start purchase-> cancel purchase
But I see crashes in this case: start app-> start purchase-> cancel purchase-> back button (this causes Gdx.app.exit() in my case and PurchaseManager.dispose()) -> start app-> start purchase-> cancel purchase-> -> CRASH REPORT
com.prozhar.ua.spelling E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.prozhar.ua.spelling, PID: 24311
java.lang.NullPointerException: Attempt to invoke interface method 'void com.badlogic.gdx.pay.PurchaseObserver.handlePurchaseCanceled()' on a null object reference
at com.badlogic.gdx.pay.android.googlebilling.PurchaseManagerGoogleBilling.onPurchasesUpdated(PurchaseManagerGoogleBilling.java:211)
at com.android.billingclient.api.BillingClientImpl$1.onReceive(BillingClientImpl.java:136)
at com.android.billingclient.api.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:303)
at com.android.billingclient.api.LocalBroadcastManager.access$000(LocalBroadcastManager.java:44)
at com.android.billingclient.api.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:114)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Sorry for my english. Fix it faster plaese I use your perfect library in production. 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (7 by maintainers)
Top GitHub Comments
I see. It will be fixed with the two steps mentioned. I’ll add the null checks and call to endConnection next week.
This issue can be closed.