依赖关系配置 [英] Dependency configurations
本文介绍了依赖关系配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如果我创建一个使用产品口味的库,那么当我在应用程序中使用该库时,我可以在一个gradle中执行:
I know that if I make a library that uses product flavors, then when I use that library in an application, I can do this in a gradle:
dependencies {
flavor1Compile(path: '{path}', configuration: 'flavor1Config')
flavor2Compile(path: '{path}', configuration: 'flavor2Config')
}
我也知道我可以这样做:
I also know that I can do this:
dependencies {
debugCompile(path: '{path}', configuration: 'debugConfig')
releaseCompile(path: '{path}', configuration: 'releaseConfig')
}
这:
dependencies {
flavor1DebugCompile(path: '{path}', configuration: 'flavor1DebugConfig')
flavor1ReleaseCompile(path: '{path}', configuration: 'flavor1ReleaseConfig')
flavor2DebugCompile(path: '{path}', configuration: 'flavor2DebugConfig')
flavor2ReleaseCompile(path: '{path}', configuration: 'flavor2ReleaseConfig')
}
p>
But that code produces this:
错误:(30,0)找不到Gradle DSL方法:'flavor1DebugCompile()'
可能的原因:'android'可能使用不包含方法的Gradle版本。
打开Gradle包装文件构建文件可能缺少Gradle插件。
应用Gradle插件
有办法吗?
推荐答案
有一个在Android问题跟踪器上打开的错误来支持此操作。
到目前为止,您可以通过声明这样的配置您要使用的组合:
As of right now, you can accomplish this by declaring a configuration like so for each combination you want to use:
configurations {
flavor1DebugCompile
}
dependencies {
flavor1DebugCompile(path: '{path}', configuration: 'flavor1DebugConfig')
}
这篇关于依赖关系配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文