Different options based on build option in Gradle

I have two flavors in my gradle file: flavor1 and flavor2. Along with building types, they create the following assembly options:

flavor1-debug flavor1-release flavor2-debug flavor2-debug 

I guess I want to have different options for each option, where should I put it?

My folder structure

 src |__ main |__ flavor1 |__ flavor2 |__ debug |__ release 

I know, according to this , which

All resources (Android res and assets) are used using the overlay priority where Build Type overrides the Product Attribute that overrides the main sourceSet.

This means, however, that if I put it in the Build Type folder, the debug options will have the same debug drawing, and the release options will have the same release.

I suggest that from the very beginning I could create more specific flavors. flavor1release, flavor1debug, flavor2release, flavor2debug, but I would get 8 options. Perhaps I could not build some types of assembly according to this , but this does not seem very clean.

+7
android android-gradle gradle
source share
1 answer

There are actually additional source sets. You can do it:

 src |__ main |__ flavor1 |__ flavor1Debug |__ flavor1Release |__ flavor2 |__ flavor2Debug |__ flavor2Release |__ debug |__ release 

which, as I think, will give you what you want - inside one of the folders of the style + build type, you can have your resource of a certain option in the corresponding resource subdirectory.

See the docs http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Sourcesets-and-Dependencies for more information.

+9
source share

All Articles