Ошибка в валидаторе привязки данных от Ilhasoft + Kotlin

Я пытаюсь использовать библиотеку Android «Data Binding Validator от Ilhasoft» с Kotlin, но я получаю эту ошибку: Неразрешенная ссылка: validate.

Это мой root build.gradle:

buildscript { ext.kotlin_version = '1.1.60' ext.android_plugin_version = '3.0.0' ext.data_binding_validator_verson = '1.0.0' repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { jcenter() maven { url 'https://jitpack.io' } } } task clean(type: Delete) { delete rootProject.buildDir } 

Это мой APP build.gradle:

 apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' android { compileSdkVersion 27 buildToolsVersion "27.0.0" defaultConfig { applicationId "com.main.janderson.meuapp" minSdkVersion 16 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dataBinding { enabled = true } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" kapt "com.android.databinding:compiler:$android_plugin_version" compile "com.github.Ilhasoft:data-binding-validator:$data_binding_validator_verson" } repositories { mavenCentral() google() } kapt { generateStubs = true } 

Это мой файл fragment_cadastrar_user:

 <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <data> <variable name="user" type="com.main.janderson.meuapp.model.User" /> </data> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"> <ProgressBar android:id="@+id/cadastrar_user_progress" style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="@dimen/activity_vertical_margin" android:visibility="gone" /> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:id="@+id/cadastrar_form" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/first_name_user" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/first_name" android:inputType="textCapSentences" android:lines="1" android:maxLength="30" android:maxLines="1" android:text="@{user.firstName}" app:validateEmpty="@{false}" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/last_name_user" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/last_name" android:inputType="textCapSentences" android:lines="1" android:maxLength="30" android:maxLines="1" android:text="@{user.lastName}" app:validateEmpty="@{false}" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/user_email" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/prompt_email" android:inputType="textEmailAddress" android:lines="1" android:maxLength="100" android:maxLines="1" android:text="@{user.email}" app:validateType='@{"email"}' /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/user_phone" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/phone" android:inputType="phone" android:lines="1" android:maxLength="20" android:maxLines="1" android:text="@{user.phone}" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/user_pass" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/prompt_password" android:inputType="textPassword" android:lines="1" android:maxLength="20" android:maxLines="1" android:text="@{user.password}" app:validateMinLength="@{4}" /> </android.support.design.widget.TextInputLayout> <android.support.design.widget.TextInputLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:id="@+id/user_confir_pass" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/prompt_repeat_password" android:imeActionLabel="@string/cadastrar" android:imeOptions="actionUnspecified" android:inputType="textPassword" android:lines="1" android:maxLength="20" android:maxLines="1" /> </android.support.design.widget.TextInputLayout> <Button android:id="@+id/new_user_button" style="?android:textAppearanceSmall" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="16dp" android:text="@string/cadastrar" android:textStyle="bold" /> </LinearLayout> </ScrollView> </LinearLayout> </layout> 

И чтобы закончить это мой onCreateView в моем фрагменте:

 override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.fragment_cadastrar_user, null) //Binding Api val binding: FragmentCadastrarUserBinding = DataBindingUtil.setContentView(activity as Activity, R.layout.fragment_cadastrar_user) val validator = Validator(binding); binding.validate.setOnClickListener(View.OnClickListener { if (validator.validate()) { registerUser() } }) binding.setUser(user); view.user_phone.addTextChangedListener(PhoneNumberFormattingTextWatcher()) return view } 

И в дополнение к этому картина с моей ошибкой.

Может ли кто-нибудь помочь мне в этом. Благодаря!

    validate – это идентификатор кнопки в примере библиотеки.

    Вы должны использовать идентификатор кнопки, на которой вы хотите проверить. Я думаю, что это new_user_button .

    Таким образом, с привязкой, это должно быть как newUserButton .

    Итак, ваш полный пример будет таким:

     override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val view = inflater.inflate(R.layout.fragment_cadastrar_user, null) //Binding Api val binding: FragmentCadastrarUserBinding = DataBindingUtil.setContentView(activity as Activity, R.layout.fragment_cadastrar_user) val validator = Validator(binding); // CHANGE IN BELOW LINE binding.newUserButton.setOnClickListener(View.OnClickListener { if (validator.validate()) { registerUser() } }) binding.setUser(user); view.user_phone.addTextChangedListener(PhoneNumberFormattingTextWatcher()) return view }