9

在里面build.gradle我们可以

   productFlavors {
        free {
            dimension "tier"
        }
    }

然后

dependencies { freeDebugImplementation "com.someDependency:free-debug:1.0.0";}

但是当我Kotlin DSL在里面使用时build.gradle.kts,我

productFlavors { create("free") {...} }

然后在dependencies不能

dependencies { freeImplementation(...)}

错误:^ Unresolved reference: freeImplementation 那么,如何implementation通过 Kotlin DSL 获得特定的风味?

4

3 回答 3

7

Kotlin DSL风格的特定依赖项如下所示:

dependencies { 
    "freeImplementation"(...)
    "paidImplementation"(...)

}
于 2020-09-11T06:42:17.947 回答
3

您应该使用示例“YOUR_FLAVOR_NAMEimplementation”

dependencies {

    "freeImplementation" "your dependency is here"
    "paidImplementation" "your dependency is here"
    // Other dependencies    

}

于 2020-04-14T08:56:50.350 回答
0
productFlavors {
    free {
            .....
         }
    paid {
            ....
         }
}

在依赖项中这样写

dependencies {

        freeImplementation "your dependency is here"
        paidImplementation "your dependency is here"
        // Other dependencies    
}
于 2020-01-10T07:05:22.000 回答