在使用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
}
本文详细介绍在Kotlin开发的安卓项目中启用DataBinding的步骤,包括修改build.gradle文件、添加依赖以及解决编译错误的方法。
581

被折叠的 条评论
为什么被折叠?



