android - 在 gradle 中添加对特定 productFlavor 和 buildTyp

我想知道如何在 gradle 中添加对特定 productFlavor 和 buildType 的依赖。 例如我有productFlavor free 和构建类型release,如何添加对assembleFreeRelease 任务的依赖?

我尝试了许多变体,但都不起作用。

例如我试过:

task('release', dependsOn: assembleProductionRelease) {
} 
// error: Could not find property 'assembleProductionRelease' on root project 'app'.

或者:

task('release', dependsOn: 'assembleProductionRelease') {
}

这里没有错误,但是任务是针对每种风格和构建类型执行的,非常困惑。

最佳答案

有对 flavor 和 buildType 依赖项的内置支持。

dependencies {
   flavor1Compile "..."
   freeReleaseCompile "..."
}

http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Sourcesets-and-Dependencies

关于android - 在 gradle 中添加对特定 productFlavor 和 buildType 的依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19589342/

相关文章:

build - 您如何启动并运行构建服务器?

ant - Apache ant 无法识别 'for' 任务/宏,虽然我已经通过 taskdef 添

build - CMake 的新手想知道哪些尘土飞扬的角落?

build - VSTS 构建所有分支

android - 如何生成 R.java

java - 如何告诉 ant 使用特定的 javac 可执行文件进行构建?

build - 使用测试报告聚合 gradle 多项目测试结果

.net - nuget安装退出代码9009

iphone - 我可以将 "Build Active Architecture Only"设置为

android - crashlytics android studio gradle 构建失败