android - Managing multiple Flavours... exponential growth? -


imagine situation in need have versions of apk or without ads, or without customjarsdk , 3 markets, googleplay, amazonapps , samsungapps.

in perfect world whould 7 flavours:

  • with ads
  • without ads
  • with customjarsdk
  • without customjarsdk
  • for googleplay
  • for amazonstore
  • for samsungapps

and in perfect world there whould way combine flavours in gradle, example:

  • with ads + samsungapps + customjarsdk
  • without ads + googleplay
  • etc...

is possible? or cursed , forzed have flavours...?????

  • for googleplay ads
  • for googleplay ads , customjarsdk
  • for googleplay without ads
  • for googleplay without ads , customjarsdk
  • for amazonstore ads
  • for amazonstore ads , customjarsdk
  • for amazonstore without ads
  • for amazonstore without ads , customjarsdk
  • for samsungapps ads
  • for samsungapps ads , customjarsdk
  • for samsungapps without ads
  • for samsungapps without ads , customjarsdk

it quite difficult answer question. depends resources different in flavor.

currently you can't extend flavors or merge them.

however can use use tips improve project.

for example can use common sourceset resources different flavors.

something that:

+ app // module |- src    |- common // shared srcdir       |- java    + flavor1       |- java    + flavor2       |- java    + flavor3    + flavor4 

then can define somenthing this:

 sourcesets {                     flavor1.java.srcdir 'src/common/java'         flavor2.java.srcdir 'src/common/java'         flavor3.java.srcdir 'src/common/java'     } 

in case should evaluate if flavors:

  • for googleplay ads
  • for googleplay ads , customjarsdk
  • for googleplay without ads
  • for googleplay without ads , customjarsdk

can use common block:

 sourcesets {             flavor1.java.srcdir = ['src/common/java', 'src/flavor1/java']             flavor2.java.srcdir = ['src/common/java', 'src/flavor2/java']             flavor3.java.srcdir = ['src/common/java', 'src/flavor3/java']         } 

each flavor can use same sourceset defined in flavor.
somenthing that:

flavor2{         java.srcdirs = sourcesets.flavor1.java.srcdirs         res.srcdirs = sourcesets.flavor1.res.srcdirs         resources.srcdirs = sourcesets.flavor1.resources.srcdirs         aidl.srcdirs = sourcesets.flavor1.aidl.srcdirs         renderscript.srcdirs = sourcesets.flavor1.renderscript.srcdirs         assets.srcdirs = sourcesets.flavor1.assets.srcdirs     } 

also each flavor can define multiple resource folders. instance:

android.sourcesets {    flavor1.res.srcdirs = ['src/main/res', src/main/res2'] } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -