繁体   English   中英

如何在弹出的世博项目中安装反应导航?

[英]How to install react-navigation in an ejected expo project?

我正在尝试按照页面上的官方安装说明在我弹出的 expo 应用程序中安装react-navigation 在下面的说明中,典型的包添加和通过react-native link有额外的代码要添加到文件MainActivity.java

现在我的问题是,在安装指令中, MainActivity类扩展了ReactActivity类,但是由于我在代码中使用了一个弹出的 expo 应用程序,它扩展了类DetachActivity ,这似乎与安装指令的给定代码不兼容,因此我我真的不知道如何解决这个不兼容问题(特别是因为我什至无法通过谷歌找到任何关于它的东西 - 它甚至是一个没有人谈论的黑暗秘密吗?)。

我尝试过但没有奏效的一些方法:

  • 无论如何包含代码会产生错误 [编译错误] error: method does not override or implement a method from a supertype
  • 包括代码,替换DetachActivityReactActivity和删除重写的方法,所有方法DetachActivity导致应用程序死机。
  • 不包含任何内容会产生错误 [手机上的红屏] 本Native module com.swmansion.gesturehandler.react.RNGestureHandlerModule tried to override versioned.host.exp.exponent.modules.api.components.gesturehandler.react.RNGestureHandlerModule for module name RNGestureHandlerModule. Check the getPackages() method in MainApplication.java, it might be that module is being created twice. If this was your intention, set canOverrideExistingModule=true Native module com.swmansion.gesturehandler.react.RNGestureHandlerModule tried to override versioned.host.exp.exponent.modules.api.components.gesturehandler.react.RNGestureHandlerModule for module name RNGestureHandlerModule. Check the getPackages() method in MainApplication.java, it might be that module is being created twice. If this was your intention, set canOverrideExistingModule=true Native module com.swmansion.gesturehandler.react.RNGestureHandlerModule tried to override versioned.host.exp.exponent.modules.api.components.gesturehandler.react.RNGestureHandlerModule for module name RNGestureHandlerModule. Check the getPackages() method in MainApplication.java, it might be that module is being created twice. If this was your intention, set canOverrideExistingModule=true

我真的很感激一些明智的提示! 另外,我对java不是很熟悉,但我非常愿意学习一些新东西!

2019 年 12 月更新

下面无视。 现在,Expo 正在将它们的内置依赖项分离为 react-native-gesture-handler。 所以我们需要安装它。 参考

解决方案

总结一下,

回到你从博览会中弹出一个项目的提交。 并安装react-navigation 不要将其他人安装为react-native-gesture-handler

就这样。

为什么

如果你从 expo 中弹出你的项目,这些项目将依赖于 ExpoKit,所以不需要再次安装已经构建的模块。 react-native-gesture-handler就是这些模块之一。 因此,也不需要react-native link

Native module com.swmansion.gesturehandler.react.RNGestureHandlerModule tried to override versioned.host.exp.exponent.modules.api.components.gesturehandler.react.RNGestureHandlerModule for module name RNGestureHandlerModule. Check the getPackages() method in MainApplication.java, it might be that module is being created twice. If this was your intention, set canOverrideExistingModule=true.

并且此消息可能是由您再次安装的RNGestureHandlerModule引起的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM