Search code examples
androidbuildmodulegradlevariant

Android Studio Gradle - set module build variant


I am setting up project that has a dependancy to one module, and I could successfully make APK file. All I did was adding

compile project(':ModuleName')

However I am wondering if I can have module dependancy with build variance. So, [Project:debug] depends on [Module:debug], and [Project:release] depends on [Module:release]

Thanks!


Solution

  • At the moment the Gradle toolchain only builds libraries in the release variant by default, regardless of what you choose as your application build type. There are some suggested work arounds to that problem but they are mostly involved in your build configuration rather than anything with the dependency include.

    The closest example I can think that is to what you want is to do the following;

    dependencies {
        flavor1Compile project(path: ':lib1', configuration: 'flavor1Release')
        flavor2Compile project(path: ':lib1', configuration: 'flavor2Release')
    }
    

    But this is achieved through build flavours rather than build variants.