Issue: Android crashes nondeterministically when restoring from background

Hi there,

We have encountered an issue where the standalone apk force closes with message “MYAPPNAME has stopped” after returning to it after an extended period of time (1 hour or more). adb debugging provides the following exception below and there is an issue with react-native-screens (link below) that smells like its the problem. There is a workaround but it involves adding some code to activity that extends ReactFragmentActivity which is inside expo.

https://github.com/kmagiera/react-native-screens/issues/17

12-05 13:38:53.231 8700 8700 E AndroidRuntime: FATAL EXCEPTION: main
12-05 13:38:53.231 8700 8700 E AndroidRuntime: Process: com.venterraliving.pocketencasa, PID: 8700
12-05 13:38:53.231 8700 8700 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.venterraliving.pocketencasa/host.exp.exponent.experience.ShellAppActivity}: android.support.v4.app.i$b: Unable to instantiate fragment abi30_0_0.host.exp.exponent.modules.api.screens.Screen$ScreenFragment: calling Fragment constructor caused an exception
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.app.ActivityThread.-wrap11(Unknown Source:0)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6494)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: Caused by: android.support.v4.app.i$b: Unable to instantiate fragment abi30_0_0.host.exp.exponent.modules.api.screens.Screen$ScreenFragment: calling Fragment constructor caused an exception
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.support.v4.app.i.instantiate(Fragment.java:386)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.support.v4.app.k.a(FragmentContainer.java:33)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.support.v4.app.s.a(FragmentState.java:79)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.support.v4.app.o.a(FragmentManager.java:3080)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.support.v4.app.l.a(FragmentController.java:152)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.support.v4.app.j.onCreate(FragmentActivity.java:330)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at host.exp.exponent.experience.f.onCreate(ReactNativeActivity.java:140)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at host.exp.exponent.experience.a.onCreate(BaseExperienceActivity.java:79)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at host.exp.exponent.experience.ExperienceActivity.onCreate(ExperienceActivity.java:160)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at host.exp.exponent.experience.ShellAppActivity.onCreate(ShellAppActivity.java:22)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7009)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7000)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: … 9 more
12-05 13:38:53.231 8700 8700 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at java.lang.reflect.Constructor.newInstance0(Native Method)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at android.support.v4.app.i.instantiate(Fragment.java:364)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: … 22 more
12-05 13:38:53.231 8700 8700 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Screen fragments should never be restored
12-05 13:38:53.231 8700 8700 E AndroidRuntime: at abi30_0_0.host.exp.exponent.modules.api.screens.Screen$ScreenFragment.(Screen.java:19)
12-05 13:38:53.231 8700 8700 E AndroidRuntime: … 25 more

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.