数据绑定不存在:如何解决? [英] databinding does not exist: How to solve it?

查看:59
本文介绍了数据绑定不存在:如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有数据绑定功能的Android应用程序,但我总是遇到下一个错误:

I'm working on an Android application with databinding but I've always next error:


错误: my.package.databinding 不存在。

这里是我的 build.gradle 在项目级别:

Here is my build.gradle on project level:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

我还启用了构建中的绑定。 gradle 文件在模块级别。

I've also enabled binding in the build.gradle file on module level.

现在我的问题是,为什么会出现此错误,我该如何解决?

Now my question is, why occurs this error and how could I solve it?

推荐答案

如果您的项目无法编译,通常会出现此问题。 Android数据绑定应在命名包中生成代码,但如果项目没有首先编译,则无法执行此操作。

This problem occurs usually if your project does not compile. Android databinding should generate code in the named package, but it can't do that if the project doesn't compile in the first place.

要解决此问题,请携带投影到可以编译的地步。如有必要,请为此关闭数据绑定。

To solve this, bring your project to a point where it compiles. If necessary, turn databinding off for this.

这篇关于数据绑定不存在:如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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