title: How to efficiently write an Android app with different build flavours targetting different versions of the same private library
body: <p>I'm writing an app which can be built in several flavours (only 3 today, probably 20-30 on the long term).</p>
  
  <p>The app is one big Android project in one simple git repo right now. It has several features (mostly isolated in their own java package), there are about 4 or 5 of them today I don't see this growing above a dozen on the long term.</p>
  
  <p>For the sake of simplicity let's say the app comes in two flavours, Flavour 1 and Flavour 2, and offers three features,
  Feature 1 Feature 2 and Feature 3.</p>
  
  <p>Right now Flavour A uses all features and Flavour B uses Feature 1&amp;2. This setup is controlled externally by a server configuration, but it is really a business decision that is known well in advance (ie at build time), and the code of Feature 3 could be stripped out of the Flavour B build without too much trouble: by isolating Feature 3 in a library project and only include it for Flavour A in the app's build.gradle.</p>
  
  <p>The catch is that besides stripping the code of an unused feature out, I also have the following requirement: flavours must be able to use a specific version of a feature. For instance, Flavour A will use Feature 2 v1.0 and Flavour B will have to use Feature 2 v1.1. We can assume the features don't depend on each others.</p>
  
  <p>Flavour A:</p>
  
  <ul>
  <li>Feature 1 v1.0</li>
  <li>Feature 2 v1.0</li>
  <li>Feature 3 v1.0</li>
  </ul>
  
  <p>Flavour B:</p>
  
  <ul>
  <li>Feature 1 v1.0</li>
  <li>Feature 2 v1.1</li>
  </ul>
  
  <p>I'd like to keep things as simple as possible. The solution I see is to isolate features in their git repository, version them and push them on a private repository such as Nexus, and in the app's build.gradle file include the aar I need for each flavour. Flavour A would depend on Feature 2 v1.0 and Flavour B on Feature 2 v1.1. </p>
  
  <p>I need to actually set this up to see if that's viable but I already anticipate the tedious development phase of a feature. How am I supposed to test a feature I'm currently developping when I need to test it in the context of the main app, and reference the aar on a Nexus server? Do I have to push a dummy version on each code change (how many versions am I going to end up with?) Should I comment out the aar dependency while developping and reference the local library folder instead so that it uses my local code? Can two developers work on the same feature?</p>
  
  <p>More generally, is this the good approach or do I have better options?</p>