Android DataBinding error. Could not find accessor

After hours of trial and error it seems that Android data-binding looks for getters before it looks at public fields. My Order object had a helper method called getAddress

public class Order {
    public Address address;

    public String getAddress() {
        return address.addressLine1 + address.addressLine2;
    }
}

The binder was calling that method instead of accessing the public Address field. I put the getAddress method inside the Address object (where it probably should have been to begin with) and the app compiled.


Android DataBinding error. Could not find accessor

  • As this error tells, binding needs accessor or getter to work and also setter if you use two way binding.
  • So always put getter & setter in your model class.