Gradle dependency based on both build type and flavor

前端 未结 4 1313
你的背包
你的背包 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:17

    Follow up @dooplaye's example, assume you only want to compile leanback in one flavor, you could refer to below snippet:

    applicationVariants.all { variant ->
        def flavorString = ""
        def flavors = variant.productFlavors
        for (int i = 0; i < flavors.size(); i++) {
            flavorString += flavors[i].name;
        }
    
        if (flavorString.equalsIgnoreCase("pubdeb")) {
            dependencies {
                compile('com.android.support:leanback-v17:22.2.1')
            }
        }
    }
    

提交回复
热议问题