一个项目下有多个Android应用程序模块 [英] Multiple Android Application Modules Under One Project

查看:343
本文介绍了一个项目下有多个Android应用程序模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目中有两个"android应用程序模块",它们创建了独立的apk. 但是我想将这两个模块组合成一个模块,从而在模块之间创建依赖关系,以便可以生成一个apk,并且一个"android应用程序模块"可以调用另一个"android应用程序模块"的活动.

I have two 'android application modules' in one project and they create independent apks. 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'.

大多数示例建议我将一个"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.

请提出一些想法.

推荐答案

所以我想出了解决此问题的正确方法.

So guys I figured the right way to handle this problem.

因此,我在具有2个android应用程序模块的项目下创建了一个占位符库模块,并修改了该库模块的build.gradle(即我引入了android SourceSet对象)以指向另一个库的source(src和res文件夹)我想合并到其他应用程序模块中的应用程序模块.

So I created a placeholder library module under the project that had 2 android application modules and modified the build.gradle(i.e. 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.

通过这种方式,两个应用程序模块可以共存于同一项目下,而您不必触摸要转换为库模块的应用程序模块.

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).

唯一的区别是,此库模块的清单文件对其任何活动都将不具有"LAUNCHER"意图过滤器,因为应用程序模块不能具有多个LAUNCH活动.

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.

这样,您仍然可以拥有2个独立的apk,并继续独立开发应用程序;如果要在另一个应用程序中包含一个应用程序,则可以使用占位符库模块来指向应用程序模块的源.

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.

这篇关于一个项目下有多个Android应用程序模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆