Kotlin與DataBinding使用注意事項

在使用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
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章