-
-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android crash: "Unable to instantiate fragment com.swmansion.rnscreens.ScreenFragment #1697
Comments
Hey! 👋 The issue doesn't seem to contain a minimal reproduction. Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem? |
Hey @swiggyrahulgupta5, |
@swiggyrahulgupta5 Have you solved the issue? I have also face this issue to on Samsung devices |
Facing same issue on react-native:0.73.7 |
Add this to your MainActivity.java if you are using java in your react native import android.os.Bundle; or add this to your MainActivity.kt if you are using Kotlin in your react native import android.os.Bundle |
@mostafahpater - Thanks for your reply. Appname>android>app>src>main>java>com>MyApp>MainActvity.kt |
@gkasireddy202 |
did this work for you? |
I tested this fix on Pixel 8 and did not face this issue on Pixel 8. |
Let me try with this solution. |
Description
I am react-native-screens in my application.
My app is a tab bar with 5 fragments one of which is a react native module and 1 tab is an activity with a react native module as well.
When i open the fragment with the react native code,
then open the activty and navigate back and forth between these two, i get this crash:
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
Fragment A (React Native) has Activity A as a parent
Activity B(React Native)
So there are two different things here (mind my english) but then how is this causing this ScreenFragment issue?
Is ScreenFragment singleton?
Please advice how can i keep separate instances of react native navigation if i have 2 different react native components one is loaded in a fragment and one in an activity in the same app
Steps to reproduce
Create a Fragment with react native screens
Create an activity with react native screens
Navigate back and forth between these two will cause this crash
Snack or a link to a repository
https://stackoverflow.com/help/mcve
Screens version
3.8.0
React Native version
0.69.0
Platforms
Android
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Fabric (New Architecture)
Build type
None
Device
Android emulator
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: