我正在将基于Groovy的脚本迁移到Kotlin。除了不确定如何添加特定风味的依赖项之外,我已经能够完成大部分工作。 到目前为止,这就是Kotlin DSL的样子,但不确定为什么freeImplementation(“ bar:2.2.8”)
productFlavors {
create("free") {
...
...
}
create("paid") {
...
...
}
}
dependencies {
implementation("foo:1.2.0")
// This is not working when migrated to Kotlin DSL
freeImplementation("bar:2.2.8")
//Below was the code in Groovy which was working fine earlier
//freeImplementation "bar:2.2.8"
}
答案 0 :(得分:2)
下面是解决方案。
val freeImplementation by configurations
dependencies {
freeImplementation("bar:2.2.8")
}
或者,字符串文字可以用来表示动态配置:
dependencies {
"freeImplementation"("bar:2.2.8")
}