在使用kotlin开发的安卓项目中,开启DataBinding步骤如下:
1.在app的build.gradle的android配置项下添加如下:
dataBinding{
enabled = true
}
2.在app的build.gradle中引入:
apply plugin: 'kotlin-kapt'
3.在dependencies中添加:
kapt 'com.android.databinding:compiler:$version'
4.如果编译遇到如下报错:
[kapt] Incremental annotation processing requested, but support is disabled because the following processors are not incremental:
android.databinding.compiler.Processor (NON_INCREMENTAL),
android.databinding.compiler.xxxxx (NON_INCREMENTAL).
请在android配置项下添加
kapt {
generateStubs = true
}