简体   繁体   English

Android项目和Gradle:组装单个模块

[英]Android project and Gradle: assemble a single module

I have an Android Studio project that contains several sub-projects (aka: modules). 我有一个包含几个子项目(又名:模块)的Android Studio项目。 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 我在Android开发指南中读到,您只需运行即可构建项目

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? 从命令行,但这总是构建整个项目(所有模块)我只想组装一个模块,我该怎么做?

Another way to do this is: 另一种方法是:

gradlew.bat :myModule:assembleDebug

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

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

-a only builds the component and does not rebuild its dependencies -a仅构建组件,不重建其依赖项

Use -b to specify another Gradle build file. 使用-b指定另一个Gradle构建文件。 In this case, the module's instead of the top-level build.gradle. 在这种情况下,模块而不是顶级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. 如果你没有使用Gradle包装器,你也可以只需cd到模块目录并在那里运行gradle assembleDebug -a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM