Activity io.branch.unity.BranchUnityActivity has leaked IntentReceiver com.unity.purchasing.googlepl

Hello. We are using Bransch in our game. If we quit the game from the native android back button (using Application.Quit), we get this error:

Activity io.branch.unity.BranchUnityActivity has leaked IntentReceiver com.unity.purchasing.googleplay.GooglePlayPurchasing$5@398122e that was originally registered here. Are you missing a call to unregisterReceiver()?

Anyone has an idea on how to solve that error? It causes big troubles next time we start the app and try to initialize the Unity IAP.

Here is our log:

Note, we are using the latest Unity IAP version.

Sorry, what is Bransch? How does it affect IAP on the next app launch? Typically you should not put much logic in Application.Quit as services and components are in the process of unloading. I’m not seeing any IAP mention in the logs. And you are quitting the game when the user presses the back button? Why is that?

Thanks for answering @JeffDUnity3D .
Branch is a deep-linking plugin … https://branch.io
Well, I guess it’s kind of common to use the physical back button to quit the game on Android devices? it was actually a request from the google team (they asked for that when they were about to feature our game). We are only making the call to Application.quit when pushing the button, nothing else in that call.

com.unity.purchasing.googleplay.BillingServiceManager seems released to Unity IAP, right? We are not using any other IAP plugin…

Next time we start the game, it crashes on the UnityPurchasing.Initialize method with a “UnityEngine._AndroidJNIHelper.InvokeJavaProxyMethod” -error.

The crash seems to happen only if we quit before the UnityPurchasing.Initialize is finished…

So IAP works when you first install. Then later the game crashes as you suggest when you click the back button. You wait until tomorrow (for example), and run the game, and now IAP does not initialize. And if you keep trying, it never initializes? The only time IAP actually works is the very first install and launch? And if you hit the back button, IAP never works again. That is quite odd if so, if I am understanding correctly. A previous launch (and crash) should not affect subsequent launches. I’m not clear on your mention “The crash seems to happen only if we quit before the UnityPurchasing.Initialize is finished.”, so you quickly hit the back button to exit the game, even before it loads? Not many users would do that, so thankfully this looks like a rare issue, right? Please provide the device logs after a new install, and not pressing the back button to trigger the (permanent) crash scenario. Then provide the subsequent logs after the crash, on next app launch. How To - Capturing Device Logs on Android Have you contacted Branch (I used to work for them, I didn’t recognize it as you had misspelled their name, great company!)

Oh, sorry about the misspelling:)
They said it was a unity engine error, referring to this post:

Yes, I press the quit app button as soon as my “main menu” is loaded, but before the iap is initialized. It should be a rare issue, unless it doesn’t behave like this entering the game in offline mode, quits and then next time has a connection (haven’t tested that yet).

I haven’t yet tested with closing the app with the app switcher, but I will do some tests with that tomorrow.
I will also send you the full logs.

Forget what I said about this happen only if we quit before the UnityPurchasing.Initialize is finished. It happens every time I use the back button and call Application.Quit. I will send you full logs in a DM @JeffDUnity3D

And can you elaborate, when this occurs, IAP never again works? Please don’t DM, post here or open a support ticket. But at any rate, I don’t believe this would be an IAP issue. If it turns out to be a Branch issue, you would need to contact them.

We are having very similar issue. Issue starts with Application.Quit() , If you kill app with Application.Quit(). These three exceptions thrown. And after you relaunch the app. Iap does not work and Googleplay services doesnt work as well.

We’re observing the same behaviour after the first Application.Quit() (without using branch library).

Tried on 2019.1.1 and 2018.3.13. We’re on unity-purchasing 2.0.3 if that matters. Any input?

Similar behavior is also being discussed here [Solved] [Android,2018.3.13] UnityPurchasing don't initialize after Application.Quit