【发布时间】:2018-11-04 18:31:25
【问题描述】:
在编译我的应用程序时,我在所有生成的 WhatFragmentOrActivityBinding 类上都收到以下错误:
error: cannot find symbol
protected WhateverFragmentOrActivityBinding(DataBindingComponent _bindingComponent, View _root,
^
symbol: class DataBindingComponent
location: class WhateverFragmentOrActivityBinding
DataBindingComponent 类似乎没有生成。
查看DataBindingComponent 的文档,我们看到:
如果使用 Dagger 2,开发者应该扩展这个接口并且 将扩展接口注释为组件。
我确实在使用 Dagger 2,所以我怀疑这可能是相关的。我自己尝试过这样做,但无济于事,并且无法在互联网上找到它。这是我尝试过的:
@Component(dependencies = [AppComponent::class], modules = [(AppModule::class), (AndroidInjectionModule::class), (ActivityBuilderModule::class)])
interface BindingComponent : DataBindingComponent
但是,由于我已经遇到了找不到符号错误,因此永远不会生成 DaggerBindingComponent 类。这似乎是先有鸡还是先有蛋的问题,所以我不确定这是否能解决我的问题。
DataBindingComponent 似乎负责处理 BindingAdapter。我有一些用于绑定 ImageView src 属性的自定义绑定适配器,但即使注释掉这些适配器也无济于事,所以我不确定它们是否相关。
我尝试从应用程序中完全删除 Dagger,但问题并没有消失。不知道还能尝试什么
u_u
【问题讨论】:
-
清理并重建您的项目
-
@Ghimire 哦,我有。这么多次。
-
您将注释处理器添加为
kapt,对吗?你有apply plugin: 'kotlin-kapt',对吧? -
@EpicPandaForce 是的
-
@JasonRidge 你找到解决方案了吗?我也面临同样的问题。
标签: android data-binding kotlin dagger-2