java - Good Practice Gradle Flavors With Class -


i looking informations how should use gradle flavors define behaviors android application.

let's want start new activity in flavor1 , not in flavor2.

as gradle doesn't override classes each other,

i have to, define activity in each flavors

app/src/      |-> flavor1/java/<package>/activity.java      |-> flavor2/java/<package>/activity.java      |-> main/java/<package> 

or, define in main folder , use enum in constant class return if in flavor1 or flavor2

app/src/      |-> flavor1/java/<package>/constant.java      |-> flavor2/java/<package>/constant.java      |-> main/java/<package>/activity.java 

my guess have mix both solutions:

  • if want create unique activity in flavor1, have create same class in flavor2 , maybe throw runtimeexception("stub!")
  • if want call activity main, have use if (constant.getflavor() == flavor1)

in opinion, coolest way use gradle flavors. want sure there no other best ways, far discovered, deal before final implementation.

is there blogged or want give own opinion ? love read you!

thanks in advance!

you can place different androidmanifest files on each flavor. example can define (let's call it) optional activity inside flavor1, class extends optional activity inside flavor1 , you're done! please note flavor androidmanifest file must specify different main androidmanifest: in case, should include <activity/> (of course inside empty <application/>)


Comments