Reputation: 93
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')
}
Upvotes: 5
Views: 6317
Reputation:
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.)
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.
Upvotes: 9
Reputation:
There is a bug in Android Studio where if you use the Gradle projects dialog to run tasks, those tasks will be run in the root context. That is, if you look carefully, even submodule tasks are run as if you ran the same task at the root level.
Solutions:
Upvotes: 0
Reputation: 6901
Simply removing the include
statement of the related module (B in this case) within the root settings.gradle
file should stop Android Studio from building B as it will exclude it from the overall Gradle project. The module will stay intact, however if you plan on modifying any code in it then re-adding the include
statement is necessary. Also note that modifying the settings.gradle
file will require a Gradle Sync for Android Studio to perform properly.
Upvotes: 1