rekire rekire - 1 year ago 168
Android Question

Two-way binding cannot resolve a setter for java.lang.String property

I am playing with the two-way binding of the data binding API which was introduced in Android Studio 2.1 AFIK.

I get this interesting error:

Error:Execution failed for task ':app:compileDebugJavaWithJavac'.

> java.lang.RuntimeException: Found data binding errors.

****/ data binding error ****msg:The expression address.street cannot cannot be inverted: Two-way binding cannot resolve a setter for java.lang.String property 'street'


loc:34:37 - 34:50
****\ data binding error ****

When I try to google that error I just find a 4 day old Japanese Twitter posting from a guy who is crying about it...


is a
. I am guessing that the problem here is
as the return value of

My idea was to defining it however this does not work for me:

@InverseBindingAdapter(attribute = "text")
public static String getText(EditText edit) {
return edit.getText().toString();

What did I miss?

Answer Source

This bug is ugly as hell and properly a bug in the data binding API. The solution is to generate a setter and a getter. I came up fast with the idea to create a setter, but not to create a getter.

Here is now my simplified model:

public class Address {
    public String street;

    public void setStreet(String street) {
        this.street = street;

    public String getStreet() {
        return street;

As you may note the getter and setter are useless, but required for two way binding.

If you think that this is a bug of the API please star my bug report: Two-way binding required setters AND ALSO getters