Android:错误找不到符号@Nullable DatabindingComponent [英] Android : Error cannot find symbol @Nullable DatabindingComponent

查看:1149
本文介绍了Android:错误找不到符号@Nullable DatabindingComponent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我更新到Android Studio 3.2.1(稳定版)时,我遇到了这个烦人的错误

I'm getting this annoying error when I've updated to Android Studio 3.2.1 (Stable)

尽管并非所有绑定文件都受到影响,但仅其中一些受到了影响. 我已经检查了有关数据绑定的教程以及以下链接:

Although not all of the binding files were affected, only some of them. I've checked out tutorials on data binding and also this link : Cannot find symbol DataBindingComponent on Android Studio 3.2 Canary 16 Kotlin project

但是我找不到解决方案,我为方法创建了处理程序,在应用程序gradle中将dataBinding设置为'true',还添加了annotationProcessor "android.databinding:databinding-compiler:3.2.0-alpha10"

But I wasn't able to find a solution, I created handlers for methods, set dataBinding to 'true' in the app gradle, also added annotationProcessor "android.databinding:databinding-compiler:3.2.0-alpha10"

我在项目中使用Java(不是Kotlin). 我的项目使用了DataBinding类中的"inflate"和"setContentView"(没有DataBindingComponent选项),但它仍然显示cannot find symbol class DataBindingComponent

I'm using Java (not Kotlin) in my project. And my project uses the 'inflate' and 'setContentView' from the DataBinding class (without the DataBindingComponent option) but it still says cannot find symbol class DataBindingComponent

示例:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SPManager.save(this, SPManager.kIsChatActivityOpened, true);

    binding = DataBindingUtil.setContentView(this, R.layout.activity_chat);
    viewModel = new ChatActivityViewModel(binding, this);
    binding.setViewModel(viewModel);

现在只停留了一段时间,我无法继续进行该项目,因为我什至无法构建它.

Been stuck on this for awhile now and I can't get on with the project because I can't even build it.

错误:

{file path}.java:307: error: cannot find symbol
  @Nullable DataBindingComponent component) {
            ^ symbol:   class MyClass location: class MyBinding

需要帮助

推荐答案

您还使用Room Architectue组件吗?

Do you use the Room Architectue Component as well?

我最近遇到了同样的错误.首先,我认为这是一个数据绑定问题,但后来我发现,这是与Room Architecture Component相关的错误.

I recently got the same error. First I thought it was a databinding issue, but then I figured out, that it was an error connected to the Room Architecture Component.

我有一个标注为实体的类,并添加了一个字段值,但是忘记为此提供getter和setter方法.完成此操作后,错误消失了.

I have a class annotated as entity and added a field value, but forgot to provide getter and setter method for this. After i have done this, the error was gone.

这篇关于Android:错误找不到符号@Nullable DatabindingComponent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆