3

We have a project with multiple flavors and each flavor has 3 different buildTypes: debug, QA and release.

productFlavors {
    flavor1 {}

    flavor2 {}

    flavor3 {}   
    }

buildTypes {
    debug {
        applicationIdSuffix ".debug"
    }

    qa {
        applicationIdSuffix ".qa"

    }

    release {
   ..
    }

But for each flavor and buildType we need different library dependency. For example:

compile 'baseUrl:myLibrary:1.0.0:flavor1Release@aar'
compile 'baseUrl:myLibrary:1.0.0:flavor1Qa@aar'
...
compile 'baseUrl:myLibrary:1.0.0:flavor3Qa@aar'

Can we add these dependencies using a Groovy script?

halfer
  • 19,824
  • 17
  • 99
  • 186
Laura
  • 2,653
  • 7
  • 37
  • 59

2 Answers2

0

I know that you can define specific dependency per buildType like this

debugCompile 'baseUrl:myLibrary:1.0.0:debugLib@aar'
releaseCompile 'baseUrl:myLibrary:1.0.0:release:Lib@aar'
  • compile: main application
  • androidTestCompile: test application
  • debugCompile: debug Build Type
  • releaseCompile: release Build Type.

Because it’s not possible to build an APK that does not have an associated Build Type, the APK is always configured with two (or more) configurations: compile and Compile. Creating a new Build Type automatically creates a new configuration based on its name.

It also seems to be working just fine with flavor as described here (but not with flavorDimensions)

Doing it for a variant (buildType+Flavor) seems a bit more work. Otherwise you could define your library as a real library project and use a syntax like this

To create a dependency on another published artifact, you need to specify which one to use:

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

From: http://tools.android.com/tech-docs/new-build-system/user-guide

Community
  • 1
  • 1
Eric Labelle
  • 1,987
  • 2
  • 15
  • 23
0

Solution

  1. If you want to create multiple build type in our single project.So you need follow this https://stackoverflow.com/a/66315794/12134511 I am use following code working is fine so don't go anywhere just follow link.

I hope this code help full for you.