- Home /
Application crashes while calling Application.Quit() ?
I am working on an android game, and i find that whenever i call application.quit() my game will crash..
Here is the code
public void Update()
{
if(Input.key(Keycode.Escape)
{
Application.Quit();
}
}
Here is the logcat
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x41b03728 self=0x41aee600
| sysTid=31780 nice=0 sched=0/0 cgrp=apps handle=1074147324
| state=S schedstat=( 0 0 0 ) utm=118 stm=42 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x41b03b28> (a java.lang.VMThread) held by tid=1 (main)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:199)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1009)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1302)
at java.util.concurrent.Semaphore.tryAcquire(Semaphore.java:382)
at com.unity3d.player.UnityPlayer.pause((null):-1)
at com.unity3d.player.UnityPlayerNativeActivity.onPause((null):-1)
at android.app.Activity.performPause(Activity.java:5235)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1233)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3145)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3114)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3092)
at android.app.ActivityThread.access$800(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1315)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)
I dont understand why this is happening ?
It seems strange to me that you use a keyboard command for an android game, that makes me think that you are testing the game in the editor. Application.Quit()
doesn't work in the editor. This information might help you solve your problem :) Good luck!
@meat5000 Oh really? Guess I learned another thing today ;) thank you.
Bump, did you get an answer ? I'm having this issue after converting my project to Unity 5. Searching around makes me think its the Google Play plugin, are you using it ?
Answer by neowedge · Dec 05, 2016 at 11:55 AM
I'm not sure if I arrive late, but, for future users, be sure that you delete all your events subscriptions on the OnDestroy of the subscriber (the event could try to trigger the event to a destroyed class).
Example:
void OnDestroy() {
if (theObjectIAmListening != null) {
theObjectIAmListening.TheEvent -= MyEventHandler;
}
}