我最近发现了这个关于 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/