我正在尝试使用kotlin和两种方式进行数据绑定以在文本视图上显示基本的android应用程序,以查看编辑文本中的更改。但我收到此错误:w:[kapt]请求了增量注释处理,但由于以下处理器不是增量处理器,因此禁用了支持:android.databinding.annotationprocessor.ProcessDataBinding(DYNAMIC)。
当我尝试使用一种方法进行数据绑定时,它运行良好,它向我显示了Contact类的名称字段成功
我的代码:build.gradle(Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(module:app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
dataBinding{
enabled = true
}
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.mvvm.demo"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
我的Contact.kt
import androidx.databinding.BaseObservable
import androidx.databinding.Bindable
class Contact( var Id:Int,
var Name:String,
var Email:String):BaseObservable() {
@Bindable
var _name: String = Name
set(value) {
field = value
notifyPropertyChanged(BR._name)
}
get() = field
}
很遗憾,此错误尚未解决。我希望该警告将在下一次更新中得到解决。由于此警告,我自11月以来一直在等待更新]
来源:https://issuetracker.google.com/issues/110061530#comment28