简体   繁体   English

一个项目下的多个Android应用模块

[英]Multiple Android Application Modules Under One Project

I have two 'android application modules' in one project and they create independent apks.我在一个项目中有两个“android 应用程序模块”,它们创建了独立的 apk。 But I want to combine these two modules into one hence creating dependencies between the modules so that one apk can be generated and one 'android application module' can invoke activities from another 'android application modules'.但我想将这两个模块合二为一,从而在模块之间创建依赖关系,以便可以生成一个 apk,一个“android 应用程序模块”可以从另一个“android 应用程序模块”调用活动。

Most of the examples suggests me to convert one 'android application module' into a 'library module' but I don't want to do that.大多数示例都建议我将一个“android 应用程序模块”转换为“库模块”,但我不想这样做。

Document here suggests that there can exist more than one 'android application module' in one project but never could I find an example that does that. 此处的文档表明,一个项目中可以存在多个“android 应用程序模块”,但我永远找不到这样做的示例。

Please suggest some ideas.请提出一些想法。

So guys I figured the right way to handle this problem.所以伙计们,我想出了解决这个问题的正确方法。

So I created a placeholder library module under the project that had 2 android application modules and modified the build.gradle(ie I introduced android SourceSet objects) of that library module to point to sources(src and res folders) of the other application module that I wanted to merge into other application module.因此,我在具有 2 个 android 应用程序模块的项目下创建了一个占位符库模块,并修改了该库模块的 build.gradle(即我引入了 android SourceSet 对象)以指向另一个应用程序模块的源(src 和 res 文件夹)我想合并到其他应用程序模块中。

In this way both the application module may coexist under the same project and you never have to touch your application module(that you wanted to convert to a library module).通过这种方式,应用程序模块可以共存于同一个项目下,您永远不必接触您的应用程序模块(您想转换为库模块)。

The only difference would be that the manifest file of this library module will not be having a 'LAUNCHER' intent filter for any of its activity since an application module can not have more than one LAUNCH activities.唯一的区别是该库模块的清单文件将没有针对其任何活动的“LAUNCHER”意图过滤器,因为应用程序模块不能有多个 LAUNCH 活动。

So this way you can still have 2 independent apks and continue to develop the applications independently and if you want to include one in the other then use a placeholder library module to point sources of the app modules.因此,通过这种方式,您仍然可以拥有 2 个独立的 apk 并继续独立开发应用程序,如果您想将一个包含在另一个中,则使用占位符库模块来指向应用程序模块的源。

Each application module creates a separate APK.每个应用程序模块都会创建一个单独的 APK。 What you may want to do is to create a library module to contain code common to both APKs and then add a dependency between them.您可能想要做的是创建一个库模块来包含两个 APK 共有的代码,然后在它们之间添加依赖项。

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

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