Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android project and Gradle: assemble a single module

I have an Android Studio project that contains several sub-projects (aka: modules). I would like to build some of these sub-projects from the command line.

I read on the Android dev guide that you can build your project by simply running

gradlew.bat assembleDebug

from the command line, however this always builds the entire project (all the modules) I just want to assemble a single module, how do I do that?

like image 671
Master_T Avatar asked May 20 '15 10:05

Master_T


People also ask

How many build Gradle file is there in one Android project?

gradle files in an Android Studio project? Save this question.

What is assemble in Gradle?

assemble will build your artifacts, and build will assemble your artifacts with additional checks. build depends on assemble , so build is sort of a superset of assemble. You can have a look on the tasks that will be executed by using the --dry-run flag. e.g.


2 Answers

Another way to do this is:

gradlew.bat :myModule:assembleDebug

https://stackoverflow.com/a/16987319/1807627

like image 84
Leo Landau Avatar answered Oct 20 '22 19:10

Leo Landau


gradlew.bat assembleDebug -a -b path/to/module/build.gradle

-a only builds the component and does not rebuild its dependencies

Use -b to specify another Gradle build file. In this case, the module's instead of the top-level build.gradle.

If you weren't using the Gradle wrapper, you could alternatively just cd to the module directory and run gradle assembleDebug -a there.

like image 42
laalto Avatar answered Oct 20 '22 19:10

laalto