android - Gradle:如何构建不同构建类型的不同风格?

标签 android build gradle

有人可以告诉我是否可以通过命令行仅构建我的不同风格中的一种?

目前我还没有看到执行的方式,例如:

gradle buildDev 

当 Dev 是我的不同风格之一。确实,我必须执行:

gradle build

所有的味道都是建立起来的。

我想跳过一些口味。 有可能吗?

谢谢

最佳答案

虽然 build 任务没有特定风格的版本,但 assembleinstall 任务有特定风格的版本。 assemble 将创建 APK; install 会将其安装在设备/模拟器上。

例如,在 this sample project ,我定义了两种产品风格(chocolatevanilla)和三种总构建类型(debugrelease夹层)。

运行 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

关于android - Gradle:如何构建不同构建类型的不同风格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21307444/

相关文章:

android - 如何知道数据库中的数据发生变化的时刻(ActiveAndroid ORM)?

java - 应用程序可以在 Eclipse 中调试/运行,但 .APK 在解析包含自定义 View 的 XML 布局时给出 .classNotFoundException

c++ - 使用 Visual Studio 构建 GMP 库?

java - Maven - 排除传递依赖

git - "Can' t 在 git 构建期间在 @INC 中找到 ExtUtils/MakeMaker.pm”

android - 将数据从 settings.gradle 传递到 build.gradle

android - android studio 3.4.2 gradle项目同步失败错误,无法解决依赖关系错误?

android - 位置重启后 Google Play 服务位置不可用

batch-file - gradle:执行任务 "type:Exec",其中包含许多带空格的参数

在纵向和横向之间切换时,Android整数xml资源值不会改变