Hi,
The following crash report appears at least twice a week in my google play console crash reports:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState at android.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1280) at android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:451) at android.app.Activity.onBackPressed(Activity.java:2166) at android.app.Activity.onKeyUp(Activity.java:2144) at com.ansca.corona.CoronaActivity.onKeyUp(CoronaActivity.java:1987) at android.view.KeyEvent.dispatch(KeyEvent.java:2633) at android.app.Activity.dispatchKeyEvent(Activity.java:2374) at com.ansca.corona.input.RaiseKeyEventTask$1.run(RaiseKeyEventTask.java:87) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4830) 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:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) at dalvik.system.NativeStart.main(Native Method)
I understand from the above report that the crash is related to pressing the back button which i handle in my app as follows:
backBtnPressed = function(event) local phase = event.phase local keyName = event.keyName if ( "back" == keyName and phase == "up" ) then storyboard.gotoScene( previousScene, {effect = "slideRight", time = 1000, params = catg} ) return true end end
In enterScene, i have the following code:
--listen to back button if \_g.isAndroid then Runtime:addEventListener( "key", backBtnPressed) end
In exitScene, i have the following code:
if \_g.isAndroid then Runtime:removeEventListener( "key", backBtnPressed) end
Here is my problem: I have never encountered the crash during testing. And I can’t reproduce the crash. All the info i have is from the developer console crash report.
Also,
1- despite the app being updated 5 times during the past 5 months, the crash appears in all versions (different corona builds).
2- it appears in a variety of devices.
3- it only appears in android versions >= 4.0.3 (4.0.3, 4.0.4, 4.1, 4.2)
In another thread, someone suggested that the error could be caused by the facebook plugin because corona only uses the fragmentManager in that plugin. However, my app doesn’t use facebook (nor any other social plugin).
Anyone else having the same issue? Does anyone have a solution for this problem? Could someone please at least point me in the right direction?
Thanks,
Luay