Flavours

Been working on a huge ass project with around 6 different flavours. Each with it’s name, package, icons, assets, server, certificates etc

Until recently, we only had to switch icons for two flavours and I would just move the assets around. But now, with 6 flavours and everything added, there was no way to do this by hand and decided to automate it.

Tried it before

Thing is, this is a project imported from Eclipse with a very strange structure. No ‘src/main’ etc. Thus I had to manually set each flavour and from where to get the resources. If anyone will ever have trouble with this, here’s how I’ve done it.

The signing certificates

Servers and packaging

There’s a subtle difference between packageName and applicationId. Basically, applicationId (the one we change) is the url at which we can find our app.

Then we have variables for the different servers we’re using. These will be called in code with BuildConfig.API_SERVER etc.

The last line of code is the interesting one. There we have the GCM certificate, we’re basically telling gradle to copy the json certificate and move it to root.

Drawables and values

This is how you should declare any files that you want a particular flavour to use.
 




Leave a Comment

Blog

Recent posts