Can anyone explain to me how I can use for each of my flavors more then just the main and the flavor specific java/src directories ? My goal is to have directories which are used by more than one flavor but not all of them.
For example I have 3 flavors : A1, A2 and B.
Is this possible ? If so, what should I put in my build.gradle file ?
And as a bonus question, can I chose in which order gradle goes looking for files in my different directories ?
For example if I have a.png declared in both A/src and A1/src, can I tell gradle to first look for this file in A/src, and only if nothing is found look for it in A1/src ?
Build Variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors. Build Type applies different build and packaging settings. An example of build types are “Debug” and “Release”.
Product flavours lets you create multiple variants of an android app while using a single codebase. To create product flavours you need to define rules in the build.
LibraryProductFlavor. TestProductFlavor. Encapsulates all product flavors properties for this project. Product flavors represent different versions of your project that you expect to co-exist on a single device, the Google Play store, or repository.
missingDimensionStrategy(dimension, requestedValues) Specifies a sorted list of flavors that the plugin should try to use from a given dimension in a dependency. proguardFile(proguardFile) Specifies a ProGuard configuration file that the plugin should use. proguardFiles(files)
As described here
As mentioned above, each sourceSet can define multiple resource folders.
You can define multiple resource folder. For example something like this:
android {
...
sourceSets {
main {
//....
res.srcDirs = ['/src/main/res']
}
flavorA1 {
res.srcDirs = ['/src/flavor1/res', '/src/commonA/res']
}
flavorA2 {
res.srcDirs = ['/src/flavor2/res', '/src/commonA/res']
}
//.....other flavors
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With