Unity Android app crashes on application quit

Hi,
I’m working unity android app and implemented back key functionality. When use pressed back application should be closed, but my app crashes on that time.

ANR in com.. (com../com.unity3d.player.UnityPlayerProxyActivity)

Application is not responding: AppWindowToken{434e9b58 token=Token{42b69a18 ActivityRecord{42571750 u0 com.**./com.unity3d.player.UnityPlayerProxyActivity t17}}}. It has been 7520.0ms since event, 5005.6ms since wait started. Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.

I’ve integrated google admob,google analytics, google play services, vungle, flurry,facebook in my app and soomla IAP.

Thanks.

In my case, the same problem happened after I integrated Admob plugin into Unity. If this is also your case, you can solve by going to the Plugin/Android/AndroidManifest.xml file and delete the entire UnityPlayerProxyActivity and then move the intent filter down under to the UnityPlayerActivity.

I’ve had this problem, and removing the ProxyActivity indeed makes it faster to quit. However, if you want to re-launch the app it will delay 4-5 seconds (until it times out and kills the window).

This error is caused by the Google Play Games plugin for Unity. We removed it and our game launches and quits as it should. That plugin ended up having several errors… We are moving to facebook’s scores.

Hope it’s useful for someone!

I have updated my Unity Pro version from 4.5.2 f1 to Unity 4.6.1
And it solved my problem. Don’t know the reason. I think it was the bug in Older version of unity while building it.

Can use :
System.Diagnostics.Process.GetCurrentProcess().Kill();
// instead of
// Application.Quit();

EDIT: Found an answer: Why don't mobile apps have a 'close' button? - User Experience Stack Exchange

The answer is: you simply don’t need to close applications manually on modern mobile operating systems

I can confirm that

"delete the entire UnityPlayerProxyActivity "

helps for quitting immediately, but I can also confirm that

“if you want to re-launch the app it will delay 4-5 seconds”

after that change.

I am using Unity 4.6.2f1 with latest admob plugin GitHub - googleads/googleads-mobile-unity: Official Unity Plugin for the Google Mobile Ads SDK

So we can assume that lib is broken? Or are we doing something wrong? I mean, why are we the only people with that problem?!

Hello,

I have a very similar problem. Could you please help me, I keep getting ANR errors in Google Play Developer Console of my game. I don’t know what causes them. I keep getting mainly these kinds:

Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)

Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 14. Wait queue head age: 5524.9ms.)

keyDispatchingTimedOut

Please help me, my game is getting slowly popular and I would like to make it without any errors and crashes. I’ve integrated into my project AdMob, FireBase, Unity IAP, and Google Play Games and I’m using Unity version 2017. Thank you.