有人可以告诉我是否可以通过命令行仅构建一种我的不同口味?
目前,我还没有看到执行的方法,例如:
gradle buildDev
开发人员是我的不同口味之一。确实,我必须执行:
gradle build
并且所有口味都在构建。
我想跳过一些口味。可能吗?
谢谢
Answers:
虽然没有build
任务的特定于版本的版本,但是assemble
and install
任务具有特定于版本的版本。assemble
将创建APK;install
将其安装在设备/仿真器上。
例如,在此示例项目,我定义了两个产品的口味(chocolate
和vanilla
)和三个总建筑类型(debug
,release
,和mezzanine
)。
运行gradle tasks
节目,其中包括:
Build tasks
-----------
assemble - Assembles all variants of all applications and secondary packages.
assembleChocolate - Assembles all builds for flavor Chocolate
assembleChocolateDebug - Assembles the Debug build for flavor Chocolate
assembleChocolateDebugTest - Assembles the Test build for the ChocolateDebug build
assembleChocolateMezzanine - Assembles the Mezzanine build for flavor Chocolate
assembleChocolateRelease - Assembles the Release build for flavor Chocolate
assembleDebug - Assembles all Debug builds
assembleMezzanine - Assembles all Mezzanine builds
assembleRelease - Assembles all Release builds
assembleTest - Assembles all the Test applications
assembleVanilla - Assembles all builds for flavor Vanilla
assembleVanillaDebug - Assembles the Debug build for flavor Vanilla
assembleVanillaDebugTest - Assembles the Test build for the VanillaDebug build
assembleVanillaMezzanine - Assembles the Mezzanine build for flavor Vanilla
assembleVanillaRelease - Assembles the Release build for flavor Vanilla
Install tasks
-------------
installChocolateDebug - Installs the Debug build for flavor Chocolate
installChocolateDebugTest - Installs the Test build for the ChocolateDebug build
installChocolateMezzanine - Installs the Mezzanine build for flavor Chocolate
installChocolateRelease - Installs the Release build for flavor Chocolate
installVanillaDebug - Installs the Debug build for flavor Vanilla
installVanillaDebugTest - Installs the Test build for the VanillaDebug build
installVanillaMezzanine - Installs the Mezzanine build for flavor Vanilla
installVanillaRelease - Installs the Release build for flavor Vanilla
uninstallAll - Uninstall all applications.
uninstallChocolateDebug - Uninstalls the Debug build for flavor Chocolate
uninstallChocolateDebugTest - Uninstalls the Test build for the ChocolateDebug build
uninstallChocolateMezzanine - Uninstalls the Mezzanine build for flavor Chocolate
uninstallChocolateRelease - Uninstalls the Release build for flavor Chocolate
uninstallVanillaDebug - Uninstalls the Debug build for flavor Vanilla
uninstallVanillaDebugTest - Uninstalls the Test build for the VanillaDebug build
uninstallVanillaMezzanine - Uninstalls the Mezzanine build for flavor Vanilla
uninstallVanillaRelease - Uninstalls the Release build for flavor Vanilla
gradle assembleChocolateDebug
将build/apk/HelloProductFlavors-chocolate-debug-unaligned.apk
被放置在您的项目中。虽然,我不能排除仅在味道鲜美的情况下才起作用的可能性。:-)
:<module>:assemble<FlavorName>
我会简化@CommonsWare给出的答案,因为通过答案我有点困惑。
考虑这些是产品口味
跑
gradlew任务
这将列出所有产品口味以及构建类型
assemble - Assembles all variants of all applications and secondary packages.
assembleAndroidTest - Assembles all the Test applications.
assembleDebug - Assembles all Debug builds.
assembleDEV - Assembles all DEV builds.
assemblePREPROD - Assembles all PREPROD builds.
assemblePROD - Assembles all PROD builds.
assembleRelease - Assembles all Release builds.
您可以从中轻松选择口味,并根据该口味生成一个版本
gradlew assemblePREPROD
gradle
没有参数的情况下运行,然后读取输出...会有运行提示gradle tasks
...