简体   繁体   English

如何构建我的react-native JS代码以在同一项目中具有多个android应用程序?

[英]How do I structure my react-native JS code to have multiple android apps in the same project?

I just finished creating an android app in react-native (RN). 我刚刚在react-native(RN)中创建了一个Android应用程序。 I need to create another app now. 我现在需要创建另一个应用程序。 A lot of code is same across both apps. 这两个应用程序之间有很多代码是相同的。 I want to create the second app within the same project and reuse all the common components rather than duplicating them. 我想在同一项目中创建第二个应用程序,并重用所有常见组件,而不是复制它们。

I went through this SO question and configure android build variants link. 我经历了这样的问题,配置android构建变体链接。 They talk about how to create a new module, gradle config and organization of java code in different source sets like src/demoDebug/, src/debug/, src/demo/ and src/main/. 他们讨论了如何在不同的源集中(例如src / demoDebug /,src / debug /,src / demo /和src / main /)创建新模块,gradle配置和组织Java代码。

I don't think this will work with react-native because the entry point of RN app is index.android.js. 我认为这不适用于react-native,因为RN应用程序的入口点是index.android.js。 For 2 apps to work out of the same project we need 2 entry points. 为了使2个应用程序可以在同一个项目中运行,我们需要2个入口点。 Is there a way to define multiple entry points in a RN android app? 有没有一种方法可以在RN android应用中定义多个入口点? Does RN support this? RN支持吗? If yes, how to organize files of the two apps in the same project? 如果是,如何组织同一项目中两个应用程序的文件?

您可以创建git子模块并将所有共享代码移至其中

暂无
暂无

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

相关问题 这些错误在我的 react-native 项目中的 React-Native 中意味着什么,我该如何修复它们? - What do these errors mean in React-Native in my react-native project and how do I fix them? 如何在反应原生的后台持久杀死Android应用程序状态 - How do I persist state for android apps killed in the background in react-native 如何从我的 react-native 项目构建 android apk? - How to build android apk from my react-native project? 如何将调试器附加到 react-native Android 应用程序中发布版本的本机代码? - How do I attach a debugger to native code of a release build in a react-native Android app? 如何为我的React Native项目合并一个Android模拟器? - How do I incorporate an Android emulator for my React Native project? Realm React-Native:从JS(反应本机代码)和android(java)访问同一领域 - Realm React-Native: Access same realm from JS(react native code) and android(java) 如何手动向本地项目添加库? - How do I add a library to react-native project manually? 我如何在没有 wifi 的情况下处理我的 react-native (Android 4.4) 应用程序? - How do I work on my react-native (Android 4.4) app where there's no wifi? 如何将原生Android应用提交到Playstore? - How do I submit a react-native android app to the playstore? 如何在Eclipse项目中包含位于项目外部目录中的本机Android代码? - How do I include in my Eclipse project, native Android code located in a directory external to my project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM