Android <include> didn't work with ViewBinding

Viewed 1068

I have an issue with this "new" Android View Binding. I get an exception when I try to use a <include> in my XML-Layout file: <include layout="@layout/teaser_agreement" />

The include file is just a basic layout file. Everything works fine if I replace the <include> tag directly with the layout code which should be included.

This is the exception from the generated class:

error: incompatible types: TeaserAgreementBinding cannot be converted to ViewDataBinding
        setContainedBinding(this.mboundView11);

Any suggestions?

Thx, Mirco

1 Answers

You will also have to wrap your teaser_agreement.xml with layout tag. So it would be like this :

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

<--!Rest of your xml code-->
......
..........
............

</layout>
Related