Msg: Can't find getter for attribute 'android: text' with value like java.lang.String in data binding?

I try to use data binding in edittext, it works fine in the morning, but unexpectedly received an error:

****/ data binding error ****msg:Cannot find the getter for attribute 'android:text' with value type java.lang.String on android.widget.EditText. file:/home/itstym/ApkProjects/Reminder/app/src/main/res/layout/activity_main.xml loc:20:4 - 34:40 ****\ data binding error ****

EditText on line 20: 4 -34: 40

 <EditText
        app:error="@{login.errorEmail}"
        android:text="@={login.userEmailAddress}"
        android:hint="Email Address"
        android:id="@+id/email_address"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:ems="10"
        android:inputType="textPersonName"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="24dp"/>

Holder for viewing:

 @Bindable
var userEmailAddress:String = String()
    set(userEmailAddress){
        field=userEmailAddress
        notifyPropertyChanged(R.id.email_address)
        /*to check Email for validation on every character inserted by user*/
        notifyPropertyChanged(BR.errorEmail)
    }
    get() {
    return field
}

What suddenly happened wrong?

The solution tried: 1. Invalid cache and restart. 2. Clear the project and rebuild the project.

+4
source share
2 answers

Remove the get () method from userEmailAddress, since Kotlin provides access to the synthetic property in it, you can directly access userEmailAddress without get ()

+1

( Matej Drobnič):

" , , .idea,.gradle gradle, Android Studio gradle ."

. , , . , , Android Studio.

0

Source: https://habr.com/ru/post/1681324/


All Articles