Exclude module on build Android Studio

Viewed 3868

I have an Android Studio project which has 3 modules in it. A, B, C. A depends on C and B depends on C. I'm trying to speed up build times, and i realised that every time i execute assembleRelease/assembeDebug task it builds ALL modules. Every time i build module A should only build A and C, because B has no dependency in that task, right? How can i avoid module B to build every time i build module A?

Module A dependencies:

dependencies {
    compile project(path: ':c', configuration: 'release')
    provided files('libs/some-lib.jar')
}

Module B dependencies:

dependencies {
    compile project(path: ':c', configuration: 'debug')
}

Module C dependencies:

dependencies {
    compile files('libs/other-lib.jar')
}
3 Answers

I've made it clear in comments that I feel that hacking settings.gradle to remove modules is a Bad Idea.

So, if you can't run Android Studio with two or more projects open, or you don't want to invoke Gradle on a command line, or you just want to disable some modules because they are not of interest to you, there actually is a supported way to do this. (At least in recent releases of Android Studio like 3.2.x.)

  1. Right-click on the top-level Project or any module in the Project view
  2. Select Load/Unload Modules...
  3. Unload the modules you don't want to be active

Since this only ever changes your local project and can never be committed by accident, this is a safe way to reduce module overhead safely. I think it even does a sync for you so you don't have to force a sync by hand.

Related