这是我的package.json文件,我已经安装了所有依赖项,但在android中仍然有问题
{
"name": "Free",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/native": "^5.7.4",
"@react-navigation/stack": "^5.9.1",
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-gesture-handler": "^1.8.0",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.11.0",
"react-navigation": "^4.4.1"
},
"devDependencies": {
"@babel/core": "7.11.6",
"@babel/runtime": "7.11.2",
"@react-native-community/eslint-config": "1.1.0",**
strong text
**
"babel-jest": "25.5.1",
"eslint": "6.8.0",
"jest": "25.5.4",
"metro-react-native-babel-preset": "0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
我收到此错误。
TypeError:null不是对象(正在评估 '_RNGestureHandlerModule.default.Direction')
有什么主意吗?
答案 0 :(得分:0)
确保您具有以下条件:
MainActivity.java:
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
并在受保护的字符串之后,将其添加到MainActivity类中
getMainComponentName() function
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
然后执行以下操作:
cd android
gradlew clean
cd ..
最后重新运行该应用:react-native run-android