Multiple Android application modules within one project

I have two "android application modules" in one project and they create independent apks. But I want to combine these two modules into one of them, creating dependencies between the modules so that one apk can be generated and one "android app" can call actions from other "android apps".

Most of the examples tell me to convert one "Android application" to a "library module", but I don't want to.

The doc here suggests more than one "android application module" can exist in the same project, but I can't find an example that does this.

Please suggest some ideas.

+3


source to share


2 answers


So guys, I figured out the right way to handle this issue.

So, I created a placeholder library module in a project that had 2 android application modules, and modified the build.gradle (i.e. I presented android SourceSet objects) of this library module to point to the sources (src and res folders) of another which I wanted to merge into another application module.

This way, both application modules can coexist within the same project, and you never have to touch your application module (which you want to convert to a library module).



The only difference would be that the manifest file of this library module will not have an intent filter "LAUNCHER" for any of its activities, since an application module cannot have more than one LAUNCH action.

This way you can still have 2 independent apks and continue to develop applications yourself, and if you want to include them in another, use a placeholder library module to specify the sources of the application modules.

+1


source


Each application module creates a separate APK. You might want to create a library module containing code common to both APKs, and then add a dependency between them.



0


source







All Articles