I understand from the documentation (reproduced below) that the Build Variants
are generated during Gradle sync
, but how could I keep a particular one "active" or selected in Android Studio
?
Problem is that after checking out a branch I find the selected Build Variant has been reset.
I can not find an "active Build Variant" setting in any project (idea
) files.
Have already seen this possibly related question.
Thanks.
Documentation from developer.android.com
:
After the [Gradle] sync completes, Gradle automatically creates build variants based on your build types and product flavors, and names them according to . For example, if you created "demo" and "full" product flavors, and kept the default "debug" and "release" build types, Gradle creates the following build variants:
demoDebug
,demoRelease
,fullDebug
,fullRelease
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.
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.
You can add a config file, say 'Appconfig. java' to your productFlavor specific source folders i.e. src/<productflavor>/java/<packagename>/Appconfig. java ; you can then use Appconfig. PRODUCT_FLAVOR in your app.
Android Product Flavors are used to create different app versions. App versions can be free or paid. They can have different themes and texts. They can use different environments or APIs. Let's assign two product flavors free and paid in our application.
A build type determines how an app is packaged. By default, the Android plug-in for Gradle supports two different types of builds: debug and release . Both can be configured inside the buildTypes block inside of the module build file.
Updates:
Probably Android Studio 3.3+ is the way to go, as a new feature Syncing only active variant was introduced.
File → Settings → Experimental → Gradle → Only sync the active variant
Here it is. The one circulated by red rectangle is the active build variant.
For how to disable the enforced gradle sync:
Go to "Settings" -> "Appearance & Behavior" -> "System Settings"
Uncheck "Synchronize files on frame or editor tab activation"
But remember to click on the "Sync Project with Gradle Files" button whenever you make changes to Gradle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With