Multiple Modules in Android Library

Multiple Modules in Android Library



Applications are now migrating to a modularized structure in order to attain quicker Gradle builds, reuse code across functionalities and to create slicker Git flows by splitting the team between the different modules.

Let us assume that we want to use library features that are not released yet but are implemented on Github or Bitbucket repository. So in order to directly use those features we can include that library as subproject in our application and we can use those features and test.
Simplest solution to include android library with multiple modules into your application project is to follow these steps:

1. Download the library (using Git, or a zip archive to unzip)

2. Create a folder “subProject” in your project.

3. Copy and paste the Downloaded Library folder to your subProject folder.

4. On the root of your project directory create/modify the settings.gradle file. It should contain something like the following: include ‘:MyApp’

Note: Let us assume we want to use ModuleA and ModuleB of library in your application

5. Copy the following lines above include ‘:MyApp’:

include ':ModuleA', ':ModuleB'
rootProject.children.each { project ->
   String relativeProjectPath = project.projectDir.path.replace(settingsDir.path, "")
   project.projectDir = new File("subProject/$relativeProjectPath")
include ':MyApp'


6. Gradle clean & build/close the project and reopen/re-import it.

7. Edit your project’s build.gradle to add this in the “dependencies” section:


a.	dependencies {
implementation project(':ModuleA')
implementation project(':ModuleB')


8. Sync the gradle and voilà you can use the library in your project.


P.s, sometimes the Android studio on Gradle sync trips the project directory structure when entire project is copied.


Please feel free to reach out if you have any questions. In case you need any help with development, installation, integration, up-gradation and customization of your Business Solutions. We have expertise in Enterprise Application Development Solutions. Connect with us for more information. [email protected]


USA408 365 4638


1301 Shoreway Road, Suite 160,

Belmont, CA 94002

Contact us

Whether you are a large enterprise looking to augment your teams with experts resources or an SME looking to scale your business or a startup looking to build something.
We are your digital growth partner.

Tel: +1 408 365 4638
Support: +1 (408) 512 1812