Crash on app launch
See original GitHub issueHello,
I have encountered a problem while using react-native-screens combine with react-navigation : sometimes the app crash when I launched it (tested on Android only). This is the error catch in Logcat in Android Studio :
Process: com.XXXX, PID: 30449
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.XXXX/com.XXXX.MainActivity}: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.swmansion.rnscreens.Screen$ScreenFragment: calling Fragment constructor caused an exception
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2825)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2900)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1601)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:251)
at android.app.ActivityThread.main(ActivityThread.java:6589)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.swmansion.rnscreens.Screen$ScreenFragment: calling Fragment constructor caused an exception
at androidx.fragment.app.Fragment.instantiate(Fragment.java:532)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
at androidx.fragment.app.FragmentManagerImpl$6.instantiate(FragmentManagerImpl.java:2848)
at androidx.fragment.app.FragmentState.instantiate(FragmentState.java:85)
at androidx.fragment.app.FragmentManagerImpl.restoreSaveState(FragmentManagerImpl.java:2485)
at androidx.fragment.app.FragmentController.restoreSaveState(FragmentController.java:195)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:288)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:106)
at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:51)
at com.XXXX.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2900)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1601)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:251)
at android.app.ActivityThread.main(ActivityThread.java:6589)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at androidx.fragment.app.Fragment.instantiate(Fragment.java:514)
at androidx.fragment.app.FragmentContainer.instantiate(FragmentContainer.java:57)
at androidx.fragment.app.FragmentManagerImpl$6.instantiate(FragmentManagerImpl.java:2848)
at androidx.fragment.app.FragmentState.instantiate(FragmentState.java:85)
at androidx.fragment.app.FragmentManagerImpl.restoreSaveState(FragmentManagerImpl.java:2485)
at androidx.fragment.app.FragmentController.restoreSaveState(FragmentController.java:195)
at androidx.fragment.app.FragmentActivity.onCreate(FragmentActivity.java:288)
at androidx.appcompat.app.AppCompatActivity.onCreate(AppCompatActivity.java:106)
at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:51)
at com.XXXX.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2900)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1601)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:251)
at android.app.ActivityThread.main(ActivityThread.java:6589)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.IllegalStateException: Screen fragments should never be restored
I didn’t have this issue when I was using react-native-screens 1.0.0-alpha.22
with react-navigation 3.11.0
on react-native 0.59.4
.
I don’t really know what could be the cause of this issue. I didn’t have it before upgrading and it only appears sometimes.
My setup: react-native: 0.60.5 react-navigation: 4.0.7 react-native-screens: 2.0.0-alpha.3 OS: Android 8.0.0 Device: real
Issue Analytics
- State:
- Created 4 years ago
- Reactions:17
- Comments:19 (1 by maintainers)
Top Results From Across the Web
App crashing immediately on start up after upgrading to iOS12.
Running fine in simulator but crashes in device. No crash logs recorded. In line error shown after launching the app Thread 1: EXC_BAD_ACCESS...
Read more >9 Fixes for When Your iPhone Apps Keep Crashing
Then, head to your Home Screen to relaunch the app. 3. Update the App. Developers often release app updates to fix bugs and...
Read more >Crashes - Android Developers
An Android app crashes whenever there's an unexpected exit caused by an unhandled exception or signal. An app that is written using Java...
Read more >How to Fix Crashing Apps on an iPhone or Android?
If you have an app that does not respond when you try to interact with it on your smartphone screen, the traditional fix...
Read more >Why do my apps keep crashing on Android, How to fix it
How to fix apps that keep crashing on Android · 1. Force stop the app · 2. Restart the device · 4. Reinstall...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Alaa-Ben @vivekraj I tried all the solutions presented here for both navigation and flipper. I have version 0.63.2 and my problem persists, any solution?
I missed something during the Installation.
Fixed the issue by adding below lines to dependencies section in android/app/build.gradle
implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'