Search code examples
androidandroid-gradle-pluginandroid-resourcesandroid-productflavors

Android gradle - have both debug and release resources in different flavors


I want to be able to set up different things for debug and release versions of my app, for my two flavors. The things I am thinking I need are, app name, app icon, and some strings that are used for keys for various third party libs e.g. Flurry, Crashlytics.

I can get debug to work if I just create a folder called debug, but it will be the same resources for both flavors and I want them for diff flavors.


Solution

  • Create sourcesets for the build variants.

    Suppose you have vanilla and chocolate product flavors, and debug and release build types, and you want distinct resources for each combination. Create:

    • src/main/
    • src/vanillaDebug/
    • src/chocolateDebug/
    • src/vanillaRelease/
    • src/chocolateRelease/

    and put the resources where they need to go.