Charming Wong
Charming Wong

Reputation: 121

ViewBinding has a conflict with DataBinding

In my project, ViewBinding has a conflict with DataBinding when compiling. enter image description here

LayoutListCoverMaskBinding is a subclass of ViewBinding, but the parameter requires a type of DataBinding enter image description here

My layout file: enter image description here

Both DataBinding and ViewBinding are enable

viewBinding {
    enabled = true
}
dataBinding {
    enabled = true
}

Can someone clarify me why this happen and if there is a way to solve it?

Upvotes: 2

Views: 1753

Answers (2)

SomeOne
SomeOne

Reputation: 41

You should do as Guni suggested if you want to maintain then both. But, I will suggest to use only viewBinding because it is much faster and with it you don't have to wrap any view groups with and its syntax is simplified. If you want to use two ways binding then you can combine both (viewBinding and dataBinding). Chose only one to avoid troubles.

Upvotes: 0

guni
guni

Reputation: 322

You must wrap into <layout></layout> tags all of your layouts that are included in DataBinding layouts otherwise ViewBinding framework will generate its own binding for it and this is incompatible with the binding used by DataBinding.

So make sure that the root element of your layout_list_cover_mask.xml is a <layout>

Upvotes: 2

Related Questions