我正在为纯 RN 0.61.2 应用程序使用 React-Navigation 。在调试模式下使用时,该应用程序可以完美运行。但是,在发布模式下,当我尝试打开抽屉导航菜单或在 Tab 菜单中向下滚动时,该应用程序立即崩溃。
依赖项:
...
"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"
},
...
我已经将以下代码行添加到android/app/build.gradle
的依赖项中:
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
在App.js中,我尝试了
import {enableScreens} from 'react-native-screen';
enableScreens();
还有
import {useScreens} from 'react-native-screen';
useScreens();
具有2.0.0-alpha.1
的{{1}},2.0.0-alpha.3
和1.0.0-alpha.23
版本。
但是,我仍然得到相同的结果:“调试”模式运行正常,在“抽屉导航”或“标签导航”滚动后,“释放”模式急剧崩溃。
解决方案
我用react-native-screens
看到了:
adb logcat
我搜索了它,发现有些人通过在“ app.js”文件顶部导入“ react-native-gesture-handler”来修复它。所以我添加了:
ReactNativeJS: Invariant Violation: Unsupported top level event type "onGestureHandlerStateChange" dispatched
它现在运行良好!