Android DataBinding 构建错误

Android DataBinding build error

Android 的数据绑定库有问题。 我有一个新安装的 Android Studio v2.0 和新创建的项目。 问题是当我尝试添加

dataBinding {
    enabled = true
}

我的 build.gradle,我在尝试构建项目时遇到此错误: :app:dataBindingProcessLayouts调试失败 Error:Execution 任务“:app:dataBindingProcessLayoutsDebug”失败。

Could not initialize class android.databinding.parser.XMLLexer

build.gradle 个文件如下所示:

buildscript {
    repositories {
        jcenter()
    }
dependencies {
    classpath 'com.android.tools.build:gradle:2.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
    repositories {
        jcenter()
    }
}
    task clean(type: Delete) {
    delete rootProject.buildDir
}

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

defaultConfig {
    applicationId "com.silgrid.test"
    minSdkVersion 14
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
dataBinding {
    enabled = true
}
}

dependencies {
}

有谁知道如何解决这个问题? 谢谢。

对我来说,它在更新到 Android Studio 2.2

后得到修复

更新主 gradle 文件中的 gradle 版本已经为我解决了这个问题。

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "com.android.databinding:dataBinder:1.0-rc1"
        classpath 'com.google.gms:google-services:4.1.0'
    }
}