java - How to install react-navigation in an ejected expo project?
问题描述
I am trying to install react-navigation
in my ejected expo app by following the official install instructions on this page. Within the instructions below the typical addition of the package and linking via react-native link
there is additional code to be added into the file MainActivity.java
.
Now my problem is that in the install instructions the class MainActivity
extends the class ReactActivity
, but since I use an ejected expo app in my code it extends the class DetachActivity
, which seems to be incompatible with the given code of the install instruction and therefore I am really clueless how to approach that incompatibility problem (especially since I am not even able to find anything via google about that - is it even a dark secret nobody talks about?).
Some approaches I tried but did not work:
- Including code anyways produces error [compiling error]
error: method does not override or implement a method from a supertype
. - Including code, replacing
DetachActivity
withReactActivity
and removing all methods overriding methods ofDetachActivity
results in crash of the app. - Not including anything produces error [red screen on phone]
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
.
I would really appreciate some wise tips! Also, I am not very familiar with java but am totally willing to learn some new stuff!
解决方案
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
您再次安装造成的。
推荐阅读
- angular - Http.get() 在 Ionic 4 的构建(发布/调试)中工作但不工作
- angular - 使用 Angular 自定义组件 (ControlValueAccessor) 在 Safari 中出现奇怪的焦点行为
- vba - 使用 Microsoft Outlook 15.0 对象库的文件可移植性
- ios - swift 5中如何在多个动态collectionview单元格中使用图像或没有图像的多个标签芯片?
- python - 如何在 Django 模板语言中循环 ajax 响应数据?
- xml - 致命错误:schemaLocation 属性不包含值对
- javascript - 如何使用 chrome 控制台更改颜色
- java - 如果调用在 Spring 中引发 RuntimeException 的私有方法,@Transactional 方法是否应该回滚?
- neo4j - 建模实践 - Neo4j
- google-cloud-storage - 是否可以从已授权访问 GS 存储桶的谷歌账户授权谷歌服务账户?