Gradle dependency based on both build type and flavor

前端 未结 4 1323
你的背包
你的背包 2020-12-07 16:27

I have several build types: debug, release. I also have two flavors pub and dev.

pub flavored applic

4条回答
  •  醉酒成梦
    2020-12-07 17:07

    Take a look at Multi-flavor variants You shouldn't use buildTypes for this. But you can define multi-flavors:

    flavorDimensions "first", "second"
    
    productFlavors {
        pub {
            flavorDimension "first"
        }
        dev {
            flavorDimension "first"
        }
        deb {
            flavorDimension "second"
        }
        rel {
            flavorDimension "second"
        }
    }
    

    And then you can add dependencies to your libs like this

    pubRelCompile project(path: ':common', configuration: "pubRel")
    devRelCompile project(path: ':common', configuration: "devRel")
    pubDebCompile project(path: ':common', configuration: "pubDeb")
    devDebCompile project(path: ':common', configuration: "devDeb")
    

提交回复
热议问题