I'm using Android Studio RC with gradle 2.2. I have in my build variants section a few variants and I can choose which one I want to build. For example one build for Hungary or for Germany.
I have a few tasks that I launch in my gradle script like changing the name based on the flavor/variant. But at the moment the script iterates over all the build variants like so:
android.applicationVariants.each { variant ->
.
So my question is: how can I get only the chosen variant from the android studio Build Variants
section and use it in gradle script, so to remove the loop?
You can simply check the variant name and only run certain tasks for specific flavors, like this:
android.applicationVariants.all { variant ->
if (variant.name.contains('myflavor')) {
// Do stuff
}
}
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