1

I have been doing some reading on Android flavours and how to use them in SO and other resources such as

1)Building Multiple Editions of an Android App with Gradle

2)Building multiple flavours of an Android app

based on these examples, android flavours are very useful for building multiple editions of the app. but my question is:

Is it a good practice to use flavours in scenarios that service provider and consumer roles have separate app like uber or it is better to build separate projects.

what are the main attributes we need to consider before using flavours?

Poorya
  • 1,133
  • 3
  • 23
  • 50
  • Likely to be close because of opinions - you might want to try tighten the question up a bit. – Richard Le Mesurier Jul 27 '17 at 08:41
  • 1
    Flavours are best suited to apps where only the resources change (at a beginner level). They are also good when one version has a little more code than the other (but this is a bit more advanced to pull off). Having 2 very different sets of code in each flavour can become very difficult (if you are asking the question, this is not for you). e.g. one project I worked on with flavours has almost 300 different apps, different launch icons & URLs, but exact same codebase - that worked really well. – Richard Le Mesurier Jul 27 '17 at 08:43

2 Answers2

2

From Android docs:

Product flavors represent different versions of your app that you may release to users, such as free and paid versions of your app. You can customize product flavors to use different code and resources, while sharing and reusing the parts that are common to all versions of your app.

So, product flavors should be used to create customized versions of the same app. Different flavors may differ in some part of resources and functions but they are almost the same app.

For building different apps that are related to each other and share some part of code it is better to use modules. You'll have 2 application modules for apps and a library module which contains a common part of code. Application modules will depend on library module.

Artyom
  • 1,089
  • 14
  • 20
1

Creating multiple environments is different from separate apps.

As I think, the best practice is to create multiple environments for each separated app.

Like instance, for many projects, they have 2 apps, one for User and another for Admin. So in that case, we create 4 environments for each app.

Building multiple environments will maximize productivity and reduce bugs that could reach the user. There are 4 common tiers that can be helpful

Development Optional. This is the working environment for individual developers or small teams. Working in isolation with the rest of the tiers, the developer(s) can try radical changes to the code without adversely affecting the rest of the development team.

Integration A common environment where all developers commit code changes. The goal of this environment is to combine and validate the work of the entire project team so it can be tested before being promoted to the Staging Environment. It is possible for Development and Integration to be the same environment (as in the case where the developer does not use a local copy of the source code).

Staging The staging tier is a environment that is as identical to the production environment as possible. The purpose of the Staging environment is to simulate as much of the Production environment as possible. The Staging environment can also double as a Demonstration/Training environment.

Production The production tier might include a single machine or a huge cluster comprising many machines.

A very common use-case that you can delete, edit anything you want in Development environment, but you can't do the same in Production, the only one way is migrating data.

Fortunately, Android Gradle support productFlavors to support us for that stuff.

But, yeah, if you just need one environment for Admin app, which accepts bugs happen frequently, you can define only one environment.

This is a very big topic, may be this answer can help you. This is the common flow for multiple environments enter image description here

nhp
  • 3,302
  • 1
  • 11
  • 23