8

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'.

  • visit this thread: http://stackoverflow.com/questions/24860659/multi-flavor-app-based-on-multi-flavor-library-in-android-gradle/24910671#24910671 – Ali Aug 01 '14 at 21:21

2 Answers2

8

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.

Xavier Ducrohet
  • 28,383
  • 5
  • 88
  • 64
  • I want to use the dependency as project in studio, but as *.aar on the build server. How can i manage this? – Benjamin Stürmer Jun 15 '13 at 06:35
  • This is not supported at the moment. This is a well known issue in Gradle itself and it will come at some point. – Xavier Ducrohet Jun 15 '13 at 17:08
  • @XavierDucrohet Please support android library ndk prebuild – Crossle Song Jan 06 '14 at 06:32
  • 2
    Any word on when the libraries will be supporting flavors? – CasualT Jan 16 '14 at 22:10
  • They Just did: http://tools.android.com/tech-docs/new-build-system/migrating_to_09 – redDragonzz Mar 07 '14 at 09:07
  • 1
    What we did in 0.9 is not all the work we need to do for full flavor support in libraries. Make sure to read the release notes and updated documentation for current limitations. – Xavier Ducrohet Mar 07 '14 at 16:14
  • 1
    Starting from 0.9 when specifying productFlavors for one of android-library, then processReleaseRsources task fails – doesn't see custom attrs from other libs my project depends on.. – Oleksii Malovanyi May 30 '14 at 08:04
  • 1
    I can't get *android-library* flavors to work at all! Do resources not migrate automatically? I keep getting an error `No resource found that matches the name (at 'theme' with value '@style/MyStyle').` – Phil Jun 19 '14 at 14:34
-1
flavor1Implementation files('libs/user/xxx.aar')

You can use aar files like this in flavors.