机器人 - 多摇篮包含和排除库 [英] android - gradle multiproject include and exclude libraries
问题描述
我试图建立与摇篮的Android项目。
I am trying to build an Android project with Gradle.
它具有结构如下:
ProjectA----- MainProject,
LibA ---- Library project,
LibB ---- Library project,
LibC ---- Library project,
LibD ---- Library project,
etc...
根据situtation,我需要包括图书馆,有时需要包括基于口味所有的图书馆,1库,2或3等。 在设置文件我已经包括了所有项目。
Based on situtation, I need to include the libraries, sometimes need to include all libraries, 1 library, 2 or 3 etc. based on flavors. In settings file I have included all projects.
有谁知道如何包含/排除根据口味库?
Does anybody know how to include/exclude libraries based on flavors?
我已经试过的依赖块,还有我得到的错误。
以下是示例code
I have tried on dependency block, there I am getting error.
Following is the sample code
dependencies {
if (task.name.matches('compileFlovor1'){
exclude module: 'LibD'
}
}
错误是:找不到方法排除()的参数[{模块= LIBD}]
Error is: Could not find method exclude() for arguments [{module=LibD}].
请指导我解决这个问题。
Please guide me resolving this issue
推荐答案
不添加香精特定的依赖,你必须配置,根据配置。 让我们假设你有味道的自由和祈祷,
do add flavour specific dependencies you must configure the according configuration. let's say you have to flavours "free" and "payed"
android {
productFlavors {
free
paid
}
}
,那么你可以通过以下方式设置在从属模块风味特殊的依赖关系:
then you can set flavour specific dependencies in the dependency block in the following way:
dependencies {
compile project(':library1') //library1 used in free and paid flavour
freeCompile project(':library2')
paidCompile project(':library3')
paidCompile project(':library4')
paidCompile project(':library5')
}
希望帮助,
欢呼声, 勒内·
这篇关于机器人 - 多摇篮包含和排除库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!