native.requestExit(): The application has stopped unexpectedly

Hello!

Even if I have read https://forums.coronalabs.com/topic/12770-nativerequestexit-the-application-has-stopped-unexpectedly-fixed/, I still have the problem.

I have this code on my main.lua for an Android app:

local function onBackAlert(event)     if event.action == "clicked" then         local i = event.index         if i == 1 then             native.requestExit()         elseif i == 2 then             -- nada         end     end     return true end local function onKeyEvent(event) local phase = event.phase local keyName = event.keyName if ("back" == keyName and phase == "down") then native.showAlert("SALIR", "De verdad quieres salir?", {OK\_BUTTON\_TEXT, CANCEL\_BUTTON\_TEXT}, onBackAlert) return true end return false end Runtime:addEventListener("key", onKeyEvent)

When user touches OK button, the app exits, but I get a “The application has stopped unexpectedly” alert. I used the “inform” button and I got this trace on Google Developer Console:

java.lang.IllegalArgumentException: View not attached to window manager

at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:385)

at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:287)

at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:79)

at android.app.Dialog.dismissDialog(Dialog.java:323)

at android.app.Dialog.dismiss(Dialog.java:306)

at android.app.Dialog.cancel(Dialog.java:1108)

at com.ansca.corona.Controller$4.run(Controller.java:745)

at android.os.Handler.handleCallback(Handler.java:725)

at android.os.Handler.dispatchMessage(Handler.java:92)

at android.os.Looper.loop(Looper.java:153)

at android.app.ActivityThread.main(ActivityThread.java:5297)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:511)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)

at dalvik.system.NativeStart.main(Native Method)

On an other of my apps, native.requestExit() works fine.

Does someone have any idea of how to solve this?

Thank you very much!

It works fine now, but I’m not sure to having changed anything on this part on code  :unsure:

It works fine now, but I’m not sure to having changed anything on this part on code  :unsure: