I see that the library uses and relies on ReactFragmentActivity.
https://github.com/kmagiera/react-native-screens/blob/70c022c6282dfefd2d7edec5e3b382bdcb0d3a04/android/src/main/java/com/swmansion/rnscreens/ScreenContainer.java#L45
On React Native master though, this should have been removed by 0.57
https://github.com/facebook/react-native/blob/7f1fcb67e57769cfe8521756fe4c4a6e5cb64de0/ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java#L23
I am actually getting that error on RN 0.56.0
react-navigation - 2.14.0
react-native-screens- alpha.9
I have the same problem. The MainActivity generated by current React Native derives from ReactActivity.
Hey! Seems to be still available in 0.57 -> https://github.com/facebook/react-native/blob/0.57-stable/ReactAndroid/src/main/java/com/facebook/react/ReactFragmentActivity.java
In fact, there is another great PR by @dulmandakh here https://github.com/facebook/react-native/pull/20602 which makes the default ReactActivity extend AppCompatActivity. This will make it possible for Android apps to use Screens without any need to change the baseclass to ReactFragmentActivity because AppComparActivity already extends FragmentActivity.
TLDR: ReactFragmentActivity won't go away until teh default ReactActivity provides enough functionality for screens to work. In the worst case scenario you will have to change ReactFragmentActivity back to ReactActivity when upgrading to 0.58 (or when fragment activity will be ditched)
馃憢 @kmagiera - I just tested locally react-native-screens and I'm actually getting the red screen of death with the error message reported above (In order to use RNScreen components your app's activity need to extend ReactFragmentActivity or ReactCompatActivity).
Not sure what may be causing this; you should be able to repro by simply using this test proj I'm using -> https://github.com/kelset/test-react-nav-with-screens.
On iOS everything works fine.
@kelset Replace ReactActivity with ReactFragmentActivity in https://github.com/kelset/test-react-nav-with-screens/blob/3e4b4a3d1142809189a79bdad3694e82fdafab97/android/app/src/main/java/com/testnavigation/MainActivity.java#L5
@ritz078 thanks it fixed it! 馃
@kmagiera This probably can be closed :)
I updated the readme to include an information about that
According to ReactFragmentActivity.java it will be removed in 0.59. In fact, this recently merged PR removes all of the overriden methods from ReactFragmentActivity and makes ReactActivity extend FragmentActivity. It doesn't look like it has been released yet, though. So I'm guessing react-native-screens will need to take advantage of that once it's out :)
Thanks for pointing that out @noahtallen
I was aware that such a change was planned but wasn't following the updates on it. I'll make sure to update docs and glad to hear about this change as it will mean the configuration of screens is going to be simplified.
@noahtallen / @kmagiera -- For somebody using React-Native 59, what are the current in-progress instructions regarding how to use react-native-screens?
Do I need to do anything to MainActivity? -- Even using react-native 0.59.1 (Which has FragmentActivity as a parent class of ReactActivity) it still reports that onCreate is not a method in the super class.
Currently, when I enable useScreens() on react-native 0.59.0 and 0.59.1 -- without changing the base class of my MainActivity, buttons on some screens are not tappable.
(I'm using react-navigation)
Does anybody have a workaround that helps fix this? -- I'm happy to file a new Issue if that would be more helpful @kmagiera
ReactFragmentActivity is deprecated but still available in RN 0.59.5.
Just wonder when do we could use ReactActivity instead
For now it's working well with RN 0.59.5 and ReactActivity (https://github.com/facebook/react-native/pull/22662).
I get an error when i change ReactActivity to ReactFragmentActivity. I'm using "react-native": "^0.59.8", it says 'com.facebook.react.ReactFragmentActivity' is deprecated. Although the performance was increased even using ReactActivity.
You don't need to extend ReactFragmentActivity for RN 0.59 and above, as
ReactActivity already supports Fragments.
@dulmandakh thank you. This should be added to the documentation.
You can create a PR and fix documentation 馃槈
Most helpful comment
Thanks for pointing that out @noahtallen
I was aware that such a change was planned but wasn't following the updates on it. I'll make sure to update docs and glad to hear about this change as it will mean the configuration of screens is going to be simplified.