【发布时间】:2020-02-19 17:48:48
【问题描述】:
上下文
我有 3 个模块:A、B 和 app。 app 依赖于A,A 依赖于B。
自定义数据绑定适配器位于B。
app -> A -> B
所有模块都启用了数据绑定,以及 kapt 插件。
plugins {
kotlin("kapt")
}
android {
dataBinding.isEnabled = true
}
问题
假设我有以下绑定 adpater 函数:
@BindingAdapter("fontWeight")
fun TextView.setFontWeight(family: String)
在app中,我可以将其用作扩展函数,但不能将其用作自定义绑定适配器。
textView.setFontWeight("bold") // It works
<TextView
app:fontWeight='@{"bold"}' // It doesn't work
有趣的是,如果我让app 模块直接依赖于B,那么绑定适配器会按预期工作。
app -> B
有什么问题?你有什么想法?提前致谢。
更新
当我从 build.gradle.kts 中删除这行代码时,它可以正常工作,但我不知道发生了什么。
flavorDimensions("dimension")
productFlavors {
create("dev")
create("staging")
create("production")
forEach { flavor ->
with(flavor) {
dimension = "dimension"
versionCode = generateVersionCode(name)
versionName = generateVersionName(name)
if (name != "production") {
applicationIdSuffix = ".$name"
}
}
}
}
【问题讨论】:
-
@JeelVankhede 我试过了。它没有帮助。
标签: android android-databinding