Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android-library with specific Product Flavors dependency

I'm looking for something like

apply plugin: 'android-library'

dependencies {
    flavor1Compile files('utility.aar')
}

Everything fails with:

Could not find method flavor1Compile() for arguments [file collection] on root project 'SampleProject'.

like image 426
Benjamin Stürmer Avatar asked Jun 14 '13 11:06

Benjamin Stürmer


People also ask

What is missingDimensionStrategy?

void missingDimensionStrategy ( String dimension, String requestedValue) Specifies a flavor that the plugin should try to use from a given dimension in a dependency. Android plugin 3.0. 0 and higher try to match each variant of your module with the same one from its dependencies.

What is flavorDimensions?

Flavor Dimensions is a way to group flavors by a name. For now, we're using just a single group. Add the following line in your defaultConfig block: flavorDimensions "default" Now syncing the gradle would give you the following product flavors: Android Build Variants combine build types and product flavors.

What does minifyEnabled do?

So minifyEnabled removes dead code but does not obfuscate or optimize.


1 Answers

Libraries don't support flavors.

Note that this wouldn't work in a app project because you haven't defined the flavor first. You'd need to do

android {
    productFlavors {
        flavor1 {}
    }
}

dependencies {
    flavor1Compile ...
}

it wouldn't work in the other order as declaring the product flavor is what create its associated dependency configuration.

like image 154
Xavier Ducrohet Avatar answered Oct 12 '22 15:10

Xavier Ducrohet