Reputation: 3205
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.
Upvotes: 7
Views: 6323
Reputation: 1096
This can now be set in the build type with isDefault parameter.
android {
buildTypes {
debug { isDefault = true }
}
}
https://issuetracker.google.com/issues/36988145#comment59
Upvotes: 3
Reputation: 396
My understanding is that AS (as of Jul 2019) will default to the first debug variant on the list, alphabetically. If you want it to default to a specific debug variant, see if changing the name to appear first alphabetically works for you.
That said, as a regular non-dev user of Xcode and AS to get access to the builds I need, I'd say that in your specific case OP, it's probably still worth it to teach your colleague what a build variant is, how to select it, and which one is valid for your project for the cases they need to use it in if they're going to be using AS to get builds a lot. Don't just change it to avoid having to explain it to them. That's not helpful to anyone: you're making a bunch of extra work for yourself and they'll never learn anything useful from it that way.
If this is for a stakeholder, rather than having them waste their time fiddling with AS, consider looking into build distribution tools like Fabric. Devs can control what Fabric beta group gets what build(s) and variants for each app pretty well.
I hope this answer helps someone out there. And good luck, OP. :)
Upvotes: 2
Reputation: 12583
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.
Upvotes: 10