Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing build variants in bulk in AndroidStudio 3.0+

Quick history:

  • I'm using AndroidStudio 3.0
  • my project has 100+ modules (multiple applications and libraries).
  • all of them have same flavorDimensions and flavors.

Now question: how to change flavors for all modules in bulk in AndroidStudio 3.0+ without changing each application separately?

like image 555
MatrixDev Avatar asked Jan 16 '18 11:01

MatrixDev


People also ask

Where is build variants in Android Studio?

You can change the build variant to whichever one you want to build and run—just go to Build > Select Build Variant and select one from the drop-down menu. To start customizing each build variant with its own features and resources, however, you'll need to know how to create and manage source sets.

What are build variants in Android?

Build variants: Variants are the combination of build types and build flavors. For example, you can have a “dev paid” version of your app, which is a combination of the “dev” build type and “paid” flavor of your app.

What is Productflavors Android?

Product flavours lets you create multiple variants of an android app while using a single codebase. To create product flavours you need to define rules in the build.


1 Answers

There are two settings in Android Studio to enable switching all variants at once when selecting the app variant.

The settings are "Only sync the active variant" & "Do not build Gradle task list during Gradle sync". Both of them need to be disabled, then I restarted Android Studio once and Gradle sync.

Android Studio settings

With the settings in the screenshot disabled, I went from switching and waiting for ~10 seconds per dynamic-feature module (10 in my project) to one single switch in <5 seconds.

Note: This is tested in Android Studio 4.0.1

like image 73
Sebas LG Avatar answered Sep 21 '22 23:09

Sebas LG