Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AndroidX Kotlin,绑定适配器找不到参数类型为的属性的setter_Android_Kotlin - Fatal编程技术网

AndroidX Kotlin,绑定适配器找不到参数类型为的属性的setter

AndroidX Kotlin,绑定适配器找不到参数类型为的属性的setter,android,kotlin,Android,Kotlin,因此,使用androidx学习android新的架构组件时,无法使用简单的绑定适配器 下面是一个简单的文本视图 <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <data> <variable name=

因此,使用androidx学习android新的架构组件时,无法使用简单的绑定适配器

下面是一个简单的文本视图

<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">

    <data>
        <variable
                name="viewmodel"
            type="com.cleanandroidlearning.ui.livedatafunfragment.LiveDataFunViewModel" />
</data>

    <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <android.widget.TextView
                android:id="@+id/textView"
                android:textAlignment="center"
                android:text="test"
                app:testBindingAdapter="@{viewmodel.test}"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/default_margin"
                android:layout_marginRight="@dimen/default_margin"
                android:layout_marginTop="@dimen/default_margin"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"/>
    </androidx.constraintlayout.widget.ConstraintLayout>

</layout>
视图模型非常简单

class LiveDataFunViewModel() : ViewModel() {
    var test: Int = 0
}
但我总是犯这个错误

android.databinding.tool.util.LoggedErrorException: Found data binding errors.
  ****/ data binding error ****msg:Cannot find the setter for attribute 'app:testBindingAdapter' with parameter type int on android.widget.TextView. file:/Users/kenny/working/cleanandroidlearning/app/src/main/res/layout/fragment_live_data_fun.xml loc:18:42 - 18:55 ****\ data binding error ****
你们中的任何人都能看到我看不到的东西,或者用相同的架构做了一个例子

编辑:找到问题

不见了

apply plugin: 'kotlin-kapt'

在模块graddle文件中,我看不到代码有任何问题。您是否尝试过清理和重建项目。
apply plugin: 'kotlin-kapt'