-
Notifications
You must be signed in to change notification settings - Fork 29
How to use with flavor
The use of the androidsvgdrawable-plugin in conjunction with flavors is straightforward.
Generated drawable will be written in a directory specific to each flavor :
sourceSets{
main.res.srcDirs = [main.res.srcDirs, "build/generated/res/main"]
flavor1.res.srcDirs = [flavor1.res.srcDirs, "build/generated/res/flavor1"]
flavor2.res.srcDirs = [flavor2.res.srcDirs, "build/generated/res/flavor2"]
}
Remember that building your application against a flavor will merge resources in order. Flavor specific drawable will only be overriden by buildType specific resources. See http://tools.android.com/tech-docs/new-build-system/resource-merging for more informations.
For each flavor, configure a regular SvgDrawableTask
that will be executed before the android preBuild
task. A best practice is to put SVG that are specific to a flavor into a flavor suffixed directory.
task svgToPngFlavor1(type: fr.avianey.androidsvgdrawable.gradle.SvgDrawableTask) {
// pick SVG from a flavor suffixed directory
from = file('src/main/svg-flavor1')
// specify the android res folder
to = file('build/generated/res/flavor1')
// let generate PNG for the following densities only
targetedDensities = ['ldpi', 'hdpi', 'mdpi', 'xhdpi', 'xxhdpi', 'xxxhdpi']
// output format of the generated resources
outputFormat = 'PNG'
// ...
}
It is currently impossible to share SVG accross more than one flavor unless you put it within the resources of the main
sourceSet
.