Bul*_*ulu 4 build.gradle android-gradle-plugin gradle-kotlin-dsl
我正在将基于 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"
}
Run Code Online (Sandbox Code Playgroud)
下面是它的解决方案。
val freeImplementation by configurations
dependencies {
freeImplementation("bar:2.2.8")
}
Run Code Online (Sandbox Code Playgroud)
或者,字符串文字可用于表示动态配置:
dependencies {
"freeImplementation"("bar:2.2.8")
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
612 次 |
| 最近记录: |