I have an application with three different flavours and two build types. The main module defines some common interfaces and each flavour implements them. The flavours correspond to stores : google, amazon and samsung. The app proposes some in-app purchases, which is specific to each flavour.
I implemented a few debug classes to ease the integration tests of the google the flavour. The debug classes implement the IInAppBillingService and an alternative to the purchase dialog. Now the problem is that some debug classes have dependencies on a flavour. I can't switch to another flavour without having compilation errors.
I would like to keep these test classes, as they are used in integration tests. Also, they should be kept away from the release build type, to avoid any debug/testing code appearing in the released version.
My question is : how to define classes with dependencies on a flavour, but that are not used during the building of the release version ?
As you probably know, you can put code and assets specific to a flavor in its own folder under src
. For example you can have folders such as google
, amazon
, and samsung
for each flavor. You can also create debug
and release
folders for classes and assets specific to each build type. This is useful if you have code only used for development but that should not go into the final release version.
You can take this a step further and create folders for any combination of build type and flavor, for example, googleDebug
or amazonRelease
.
For automated testing, create a test
folder for unit tests which run locally on you development machine or an androidTest
folder for instrumented tests run on a device or emulator. These can also be combined with build types and flavors, for example androidTestDebug
, androidTestSamsung
, or androidTestSamsungDebug
.
All classes for testing should go under