android-studio - 一次部署多个构建变体 - Android studio gradle

标签 android-studio android-gradle-plugin build.gradle

我最近发现了这个关于 gradle productFlavors 的很棒的功能。我目前有 3 个变体(暂存、沙箱和生产),我可以使用构建变体面板一次部署其中一个变体。

有没有办法一次部署所有变体?

最佳答案

是的,
在 Android Studio 中,打开“Gradle Tasks”选项卡,通常在右侧。您将看到许多以“组装”开头的任务,双击其中之一。

例如,双击“assembleRelease”将创建您所有的发行版apk。

从文档:

Building and Tasks

We previously saw that each Build Type creates its own assemble task, but that Build Variants are a combination of Build Type and Product Flavor.

When Product Flavors are used, more assemble-type tasks are created. These are:

1) assemble[Variant Name]

2) assemble[Build Type Name]

3) assemble[Product Flavor Name]

1) allows directly building a single variant. For instance assembleFlavor1Debug.

2) allows building all APKs for a given Build Type. For instance assembleDebug will build both Flavor1Debug and Flavor2Debug variants.

3) allows building all APKs for a given flavor. For instance assembleFlavor1 will build both Flavor1Debug and Flavor1Release variants.

The task assemble will build all possible variants.

关于android-studio - 一次部署多个构建变体 - Android studio gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24648470/

相关文章:

android - CollapsingToolbarLayout 不工作应用程序崩溃

java - Android java.lang.IndexOutOfBoundsException : Invalid index 5, 大小为 5 错误

php - JSONException : Value . <!DOCTYPE of type java.lang.String cannot be converted to JSONObject 错误

android - 找不到 org.codehaus.groovy :groovy-all:2. 4.12

android - Gradle同步在Android Studio 3.6.1中失败

android - 如何在android studio中启用dex编译器D8(Next-generation Dex Compiler)

android - 运行代码时如何删除和清除 Android Studio 中 USB 设备上保存的数据?

android - 错误:Execution failed for task ':app:proguardRelease' (invalid entry CRC)

android - 如何在我离线时第一次运行 android studio?

android - 我如何知道android gradle插件的applicationVariants中的属性?