Android: different productFlavors, using different .aars. Why so.. greedy?

Hi all.
So, here’s my configuration cut down to minimal example http://www.everfall.com/paste/id.php?9y2j7e1sg6ar

I expected the following to happen after running gradlew compileMetaDebugSources or gradlew assembleMetaDebug

  • .aar dependency with specific name should be picked up via dependencies { MetaDebugSourcesCompile() } from flatDir specified within productFlavors.meta.buildTypes.debug.repositories.flatDir

Instead of that,

  • if an .aar required by Flavor2SourcesCompile is not found when building other flavor, build breaks. Why? I don’t expect for all configurations to be analyzed and started, when a specific configuration is used. I don’t want any code involved with Flavor2 to participate in building of other flavotrs.
  • regardless of configuration used, all flatDir paths are examined when looking for .aar, which completely breaks my idea of having different dirs - now I have to explicitly state the variant in library name (library-name-debug-0.0.1.aar) instead of getting it picked automatically from separate flatDir path for each ProductFlavor.buildType (/libs/debug/library-name-0.0.1.aar).

Come on, people. If I had a makefile with targets foo,bar,baz, with baz defined as baz: foo, I would definititely not expect bar target to be executed by make baz;
Why it’s different here?

I have four different .aar versions from external sources, they would not use MVN (neither do I want to do it), and I need to build four different versions of app based on flavor/build type. What can be done here?

1 Like

In general, Gradle configurations are not resolved unless they are used. I’m not certain why the Android plugin is forcing resolution of all configurations. You may want to bring it to their attention on the adt-dev mailing list.

1 Like

Even though this thread is more than one year old, I have stumbled in the same issue, so I decided to report the problem on the android bug tracker:

https://code.google.com/p/android/issues/detail?id=223597

I’m very inexperienced when it comes to gradle (and having to use it always in conjunction with the android plugin is really raising the learning curve for me…), so if anyone is interested in this issue could either comment on the report to correct any mistake on my part, and/or star the issue, I would be grateful :wink: