8

I am using React-Navigation for my pure RN 0.61.2 app. The app runs perfectly when I use it on Debug mode. However, in Release mode when I try to open the Drawer Navigation menu or scroll down in a Tab menu, the app crashes immediately.

Dependencies:

...
  "dependencies": {
    "@react-native-community/async-storage": "^1.6.2",
    "@react-native-community/netinfo": "^4.4.0",
    "@react-native-community/slider": "^2.0.2",
    "react": "16.9.0",
    "react-native": "0.61.2",
    "react-native-admob": "^2.0.0-beta.6",
    "react-native-gesture-handler": "^1.4.1",
    "react-native-reanimated": "^1.3.0",
    "react-native-screens": "1.0.0-alpha.23",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^4.0.10",
    "react-navigation-drawer": "^2.2.2",
    "react-navigation-stack": "^1.9.3",
    "react-navigation-tabs": "^2.5.5"
  },
...

I've already added these lines of code to android/app/build.gradle's dependencies:

    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

In App.js, I tried

import {enableScreens} from 'react-native-screen';
enableScreens();

and also

import {useScreens} from 'react-native-screen';
useScreens();

with 2.0.0-alpha.1, 2.0.0-alpha.3 and 1.0.0-alpha.23 versions of react-native-screens.

Yet, still I am getting the same result: Debug mode is perfectly working, Release mode is dramatically crashing after a Drawer Navigation swipe or a Tab Navigation scroll.


THE SOLUTION I used adb logcat and saw this:

ReactNativeJS: Invariant Violation: Unsupported top level event type "onGestureHandlerStateChange" dispatched

I googled it and found that some guys have fixed it by importing 'react-native-gesture-handler' on the top of the 'app.js' file. So I've added:

import 'react-native-gesture-handler'

and it is working perfectly now!

Harky
  • 91
  • 6
  • Use Android Studio Logcat to get the crash stacktrace, this should point you in the good direction... – Vinzzz Oct 16 '19 at 14:47
  • 1
    @Vinzzz Logcat output was so helpful. Thank you very much! I've added the logcat output and the solution above. – Harky Oct 17 '19 at 12:34
  • Glad you could help yourself ;) – Vinzzz Oct 17 '19 at 14:04
  • Glad you could help yourself, the solution is provided in the official documentation. It says: "To finalize the installation of react-native-gesture-handler, add the following at the top (make sure it's at the top and there's nothing else before it) of your entry file, such as index.js or App.js: import 'react-native-gesture-handler'; Note: If you skip this step, your app may crash in production even if it works fine in development." https://reactnavigation.org/docs/en/getting-started.html – asim mehmood Feb 18 '20 at 07:30

0 Answers0