Andrey Aleev
Andrey Aleev

Reputation: 331

Data Binding layout strange build error

In my project I have Android Data Binding Library v.2.3.3

After adding new aar library dependency I am getting error while compiling project with message

/Users/.../app/build/intermediates/data-binding-layout- 
out/.../debug/layout/..-activity.xml:90: error: Error: No resource found 
that matches the given name (at 'layout_above' with value 
'@id/buttonLayout').

I've checked the xml in build/intermediates and it seems quite OK:

    ...
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/mainLayout"
    android:layout_above="@id/buttonLayout">

    ...

</RelativeLayout>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="@dimen/_button_size"
    android:layout_alignParentBottom="true"
    android:id="@+id/buttonLayout">

    ...

</RelativeLayout>   
...

What may cause the problem? Is it related to databinding?
I've tried to use the aar library other project and it was working

Upvotes: 1

Views: 118

Answers (1)

Pawel Laskowski
Pawel Laskowski

Reputation: 6346

In your mainLayout you are referencing an ID @id/buttonLayout that has not been added to the resources yet as it is declared in the second RelativeLayout further down. To solve this you need to add it first with @+id like this:

...
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/mainLayout"
    android:layout_above="@+id/buttonLayout">

    ...

</RelativeLayout>
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="@dimen/_button_size"
    android:layout_alignParentBottom="true"
    android:id="@id/buttonLayout">

    ...

</RelativeLayout>   
...

Upvotes: 1

Related Questions