3

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

Most of the examples suggests me to convert one 'android application module' into a 'library module' but I don't want to do that.

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.

Please suggest some ideas.

2
  • You don't explain why you don't want to convert one to a library module -- that seems like it would be the correct solution for your case, if you don't want one of the modules to actually generate an APK. Note that the library module can't depend on the application module -- you can only depend on a library, not an application. Commented Sep 5, 2014 at 14:40
  • Ok, that means I always have to convert that independent application module into a library module in order to merge it into another application module and to be able to use this library from there. Commented Sep 8, 2014 at 17:43

2 Answers 2

3

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

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.

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.

Sign up to request clarification or add additional context in comments.

Comments

1

Each application module creates a separate 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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.