美文网首页
undefied is ... (...RNGestureHan

undefied is ... (...RNGestureHan

作者: 太阳的小号 | 来源:发表于2019-01-04 17:37 被阅读0次

    报错:undefined is not an object (evaluating 'RNGestureHandlerModule.State')

    我的项目原因:   react-native link react-native-gesture-handler  这个命令行没有运行成功,

    运行成功之后,打开xcode 运行,又报错  

    React/RCTEventDispatcher.h not found in 

    解决方案参考链接:https://github.com/kmagiera/react-native-gesture-handler/issues/179#issuecomment-450346252 

    链接中的方法就是,手动去添加 RNGesturehandlermodule, 我照着步骤执行成功了(我有空就把下面的方法翻译一下)

    1/ open your ios Podfile and delete all yout linked dependencies: pod 'xxxxxxx', :path => '../node_modules/xxxxx'

    2/ Close Xcode

    3/ In your /ios folder run "pod update"

    4/ In your project source run "react-native link"

    5/ Open Xcode and Clean Build Folder from Xcode Menu -> Product

    6/ Run your application from Xcode

    7/ Link manually the dependency "react-native-gesture-handler" into your Xcode Project following steps in documentation: https://facebook.github.io/react-native/docs/linking-libraries-ios

    8/ Now run your application from Xcode, you should be fine.

    2019.03.14 补充手动link方法

    iOS: 

    1.xcode 打开项目, 左侧栏,右击Libraries --> Add files to "***工程名**"---->node_modules--->react-navigation-gesturehandler---->......---->RNGestureHandler.xcodeproj  选中添加;

    图1

    2. 添加依赖库 libRNGestureHandler.a, 步骤如下示意图(在General栏下):

    图2

    Android:

    1.android ----> settings.gradle 文件中添加(图3):

    include ':react-native-gesture-handler'

    project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')

    图3

    2.android ---> app---->build.gradle文件中添加(图4)

    图4

    3..android ---> app---->src--->main--->java--->com--->.....---->MainApplication.java文件中添加(图5):

    图5

    备注:有的项目中,我也添加了这个:import com.facebook.react.ReactActivityDelegate;这边就不截图了

    相关文章

      网友评论

          本文标题:undefied is ... (...RNGestureHan

          本文链接:https://www.haomeiwen.com/subject/krekrqtx.html