Config for specific gradle flavor combination

android, android-gradle-plugin, android-studio, gradle

Solution

This functionality was added in version 0.7.0 of the Android plugin for Gradle

http://tools.android.com/tech-docs/new-build-system <--As of 1/6/14, this link is active

You can now have a variant specific source folder if you have flavors.

- Only for app (not library or test). Name is `src/flavorDebug/...` or `src/flavor1Flavor2Debug/`

- Note the camelcase naming, with lower case for first letter.

- Its components (res, manifest, etc...) have higher priority than components from build type or flavors.

- There is also a "flavor combination" source folder available when more than one flavor dimension is used. For instance `src/flavor1Flavor2/`

- Note that this is for all combinations of all dimensions.

- Its priority is higher than single-flavor sourcesets, but lower than build-types.

Update 1/30/2014

IntelliJ IDEA v13.0.2 (Build 133.696) now supports Android Gradle Plugin changes made in 0.7.0

Problem

I am wondering if it is possible to supply files or configuration settings for a specific flavor group combination. For example, I have 2 flavor groups, with 2 different flavors each: Flavor Group: Version - v2 - v3 Flavor Group: Type - free - full When ordered "Type", "Version" I am able to build 4 different flavors of my app: - FreeV2 - FreeV3 - FullV2 - FullV3 And my source tree looks like this: ``` /src /free /res /full /res /v2 /java /res AndroidManifest.xml (features and permissions for v2 flavors) /v3 /java /res AndroidManifest.xml (features and permissions for v3 flavors) ``` This is exactly what I want, and works very well for my project. However, I wish I could provide files for a specific flavor group combination. For example, I want to provide different AndroidManifests for FullV3 and FullV2. I don't think this is possible, or? For example: ``` /src /free /res /full /res /v2 /java /res AndroidManifest.xml (features and permissions for v2 flavors) /v3 /java /res AndroidManifest.xml (features and permissions for v3 flavors) /fullv3 AndroidManifest.xml (features and permissions for full v3 only!) /fullv2 AndroidManifest.xml (features and permissions for full v2 only!) ``` I would be nice to be able to do this in the gradle build file as well: ``` productFlavors { free { packageName ... flavorGroup "type" } full { packageName ... flavorGroup "type" } v2 { packageName ... flavorGroup "version" } v3 { packageName ... flavorGroup "version" } fullv2 { ... <-- specifically for the full-v2 combination } fullv3 { ... <-- specifically for the full-v3 combination } } ``` Note: one solution would be to only have 1 flavor group and define the 4 flavors explicitly: - freeV2 - freeV3 - fullV2 - fullV3 However, this is not a viable solution for me since I would have to duplicate all the version specific code for the free and full flavors of each version.

Original source

Related problems