我知道在基于时髦的build.gradle中,您可以定义多个排除,如下所述:
dependencies {
def withoutStuff = {
exclude group: 'com.android.support', module: 'support-v4'
exclude group: 'com.android.support', module: 'support-v13'
exclude group: 'com.android.support', module: 'design-v13'
}
// For Material Datepicker
compile deps.datePicker, withoutStuff
}
但是现在我们如何在基于 kotlin 的 build.gradle.kts 文件中执行此操作?
好的,
经过多次搜索、跟踪和错误,我想通了。在依赖项上方,您可以定义:
val withoutStuff = fun ExternalModuleDependency.() {
exclude(group = "com.android.support", module = "support-v4")
exclude(group = "com.android.support", module = "support-v13")
exclude(group = "com.android.support", module = "design-v13")
}
然后在依赖项块中,您可以执行以下操作:
dependencies {
implementation(deps.datePicker, withoutStuff)
...
}
希望对其他人有所帮助,并期待其他答案。
或者,如果要全局设置排除项,这可能有效:
// android {}
configurations {
implementation {
exclude(group = "androidx.core", module = "app")
exclude(group = "androidx.core", module = "core")
exclude(group = "androidx.appcompat", module = "app")
exclude(group = "com.google.firebase", module = "firebase-iid")
exclude(group = "androidx.test", module = "monitor")
}
}
// dependencies {}
灵感来源:https://stackoverflow.com/a/52165253/3763032