Android Bindings Shut Down

Itโ€™s just that suddenly my Android bindings stopped working, everything that I am creating now, I just get this message.

Error: execution completed for task ': app: compileDevDebugJavaWithJavac'.

java.lang.RuntimeException: Data binding errors detected. **** / data binding error **** msg: Unable to find getter for attribute 'android: text' with value of type java.lang.String on android.widget.EditText. File: C: \ path \ to \ layouts \ layout.xml loc: 85: 12 - 96:54 **** \ data transfer error ****

What i tried

At first it was suggested that the bindings should not be compiled if there were errors in my files, therefore all the layout files where I used the bindings to one file were deleted layout.xml. There I have

 <EditText
       android:layout_width="wrap_content"
       android:layout_height="match_parent"
       android:text="@{model.name}" />

... and it works well, however, if I add a two-way binding android:text="@={model.name}"It gives the previous error.

Next , I add

@InverseBindingAdapter(attribute = "android:text")
public static String captureEditTextValue(EditText view) {
    return view.getText().toString();
}

... then it gives a new error.

Error: execution completed for task ': app: compileDevDebugJavaWithJavac'.

java.lang.RuntimeException: Data binding errors detected. **** / data binding error **** msg: Could not find the event 'android: textAttrChanged' in the View field 'android.widget.EditText' File: C: \ Users \ EdgeTech \ AndroidStudioProjects \ wallet \ wallet-client \ application \ SRC \ main \ Res \ location \ get_phone_layout.xml loc: 85: 12 - 96:54 **** \ data transfer error ****

Went on to reorganize this

 @InverseBindingAdapter(attribute = "android:text", event = "android:textAttrChanged")
 public static String captureEditTextValue(EditText view) {
        return view.getText().toString();
 }

... still gives the previous error.

My setting

  • Android Studio: 2.3.3
  • Gradle Build Tools: 2.3.3
+6
4

:

ObservableField<T>

: in viewModel.class

public ObservableField<String> productName = new ObservableField<>();

layout.xml:

<EditText
       android:layout_width="wrap_content"
       android:layout_height="match_parent"
       android:text="@={viewModel.productName}" />
+3

InverseBindingAdapter, , String.

EditText XML android:text="@={model.name} โ†’ android:text="@={`` + model.name}".

+2

:

@InverseBindingAdapter(attribute = "android:text")
public static String captureEditTextValue(EditText view) {
    return view.getText().toString();
}

@InverseBindingAdapter(attribute = "android:text")
public static String getText(TextView view) {
    return view.getText().toString();
}
+1

,

. , Build Tools SDK Platform 26. , 25.

I tried all the solutions provided, all to no avail, updating it was the only solution that worked for me.

+1
source

All Articles