Я включаю привязку данных с добавлением
dataBinding {enabled = true}
и
kapt 'com. android .databinding: компилятор: 3.1.4 '
на уровне приложения * файл 1013 *.
применить плагин:' kotlin -kapt '
добавлено сверху этого. Проект основан на kotlin.
вот моя модель:
package ir.app.myapplication;
data class cisclass(val equRevId:String)
main Activity:
val binding: ActivityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main)
val user = cisclass("123")
binding.setVariable(BR.cis, user)
binding.executePendingBindings()
вот мой макет:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
<data>
<variable
name="cis"
type="ir.app.myapplication.cisclass" />
</data>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:orientation="vertical"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:text="@{cis.equRevId}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</layout>
я получу это ошибка:
java.lang.IllegalArgumentException: couldn't make a guess for ir.meedc.myapplication.cisclass
at com.squareup.javapoet.Util.checkArgument(Util.java:64)
at com.squareup.javapoet.ClassName.bestGuess(ClassName.java:171)
at android.databinding.tool.ext.ExtKt.toTypeName(ext.kt:244)
at android.databinding.tool.ext.ExtKt.toTypeName(ext.kt:192)
at android.databinding.tool.ext.ExtKt.toTypeName(ext.kt:173)
at android.databinding.tool.writer.BaseLayoutBinderWriter.createVariableFields(BaseLayoutBinderWriter.kt:229)
at android.databinding.tool.writer.BaseLayoutBinderWriter.access$createVariableFields(BaseLayoutBinderWriter.kt:39)
at android.databinding.tool.writer.BaseLayoutBinderWriter$createType$1.invoke(BaseLayoutBinderWriter.kt:67)
at android.databinding.tool.writer.BaseLayoutBinderWriter$createType$1.invoke(BaseLayoutBinderWriter.kt:39)
at android.databinding.tool.ext.Javapoet_extKt.classSpec(javapoet_ext.kt:39)
at android.databinding.tool.writer.BaseLayoutBinderWriter.createType(BaseLayoutBinderWriter.kt:63)
at android.databinding.tool.writer.BaseLayoutBinderWriter.write(BaseLayoutBinderWriter.kt:59)
at android.databinding.tool.BaseDataBinder.generateAll(BaseDataBinder.kt:65)
at com.android.build.gradle.internal.tasks.databinding.DataBindingGenBaseClassesTask$CodeGenerator.run(DataBindingGenBaseClassesTask.kt:212)
at com.android.build.gradle.internal.tasks.databinding.DataBindingGenBaseClassesTask$writeBaseClasses$$inlined$recordTaskAction$1.invoke(AndroidVariantTask.kt:52)
at com.android.build.gradle.internal.tasks.databinding.DataBindingGenBaseClassesTask$writeBaseClasses$$inlined$recordTaskAction$1.invoke(AndroidVariantTask.kt:31)
at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:91)
как я могу это исправить? в чем проблема?