Dev Story: How Android Build Variants Save Social Life

“I want to hang out with my friend”

“Wait, we need to test this app in our client environment, please adjust our app so that it can running in there”


“I just heard that they have at least 5 environment include production”

“Um, okay”.

“We need all of them to be installed in one device too, so please make sure that the service is not overwrite each other”.


That sums up the problem. If you’re a freelancer or working as android developer in software house before, you can usually find something like this.

Well, there is nothing wrong with that but if you happen to get into situation like the conversation above then it must be really annoying. I know someone that said something like “It just short project anyway so let’s make it with less effort” and well… it’s somewhat true but not like this 😉.

Instead writing important variable hardcoded like that, we need to make sure to put it in the right place. Let’s use build types for it.

But how about 5 different application environments that must all be installed in one device? Relax, you just need to update your build types like this.

Oh it looks good, then how about we make admin and customer version then make sure that admin/customer version of their client A has different behaviour with client B? Um, okay. Let’s use product flavors for that.

Next, you just need to pick the build variant based on environment & type then build/generate it…and voila you got it.

Too much effort? Honestly no, next time you got into conversation like that, it should be piece of cake. They really will save your time, trust me :D.

“Now, let me hang out with my friend…see ya”.

Leave a Reply

Your email address will not be published. Required fields are marked *