How to map build type to Android Gradle project dependency?
I have a project with two modules: library
and app
.
A module library
is of course a library and only has types release
and debug
.
The module app
has 4 flavors as well as assembly types release
and debug
, giving a total of 8 assembly options. It also declares a module dependency library
like this:
compile project(path:':library', configuration:'release')
I would like to set the config library
based on the build variant of the application: the release
build variants must use the library version release
and the build variants debug
must use the debug
library version.
The obvious answer is to list each of the 8 options and set the correct configuration and it will work, but this is not the optimal answer: it is ugly and clutters up the build script too much.
I've tried several approaches with project.configurations.all{}
and applicationVariants.all{}
, but I couldn't find a definitive way to set up the dependency configuration.
Is there a cleaner way to do this?
source to share
No one has answered this question yet