react-native-screens: Android crash: "Unable to instantiate fragment com.swmansion.rnscreens.ScreenFragment"

Description

I am using react-native-image-picker and react-native-screens in my application. about half of the times i try to pick an image taken by the camera, the app crashes throwing

AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app/com.app.MainActivity}: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.swmansion.rnscreens.ScreenFragment: calling Fragment constructor caused an exception

I found this answer in another closed issue https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067 but it does not work for my app because, i need to have the saved instance of the app being reopened, wich doesn’t happen if i set it to null(the app restarts).

this bug only happens in a few devices tested positive for motorola one hyper and motorola moto g8 power and only happens sometimes

Steps to reproduce

execute launchCamera from ‘react-native-image-picker’ click ok(or similar) after taking a picture and the app will crash when returning to the application

Snack or a link to a repository


Screens version

3.18.2

React Native version

0.70.6

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Release mode

Device

Real device

Device model

motorola one hyper

Acknowledgements

Yes

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (4 by maintainers)

Most upvoted comments

I am using latest React Native Version 0.74.2. I have a mainactivity.kt inside android/app/src/main/java

how to fix this issue please help anyone

I am using latest React Native Version 0.74.2. I have a mainactivity.kt inside android/app/src/main/java

how to fix this issue please help anyone

Have you tried adding this to your MainActivity.kt file?

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(null)
}

i have this error but only when user open my react native app, go to android settings, change font size and come back on app