6

我正在将我们基于 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"

}
4

1 回答 1

8

下面是它的解决方案。

 val freeImplementation by configurations
    dependencies {
        freeImplementation("bar:2.2.8")
    }

或者,可以使用字符串文字来表示动态配置:

dependencies {
    "freeImplementation"("bar:2.2.8")
}
于 2018-08-22T20:45:18.060 回答