I have multiple modules in my project, let's say module app and module A that act as a library for module app. I use data binding and works fine by adding
dataBinding {
enabled = true
}
in each module build.gradle.
The problem occurred when I including layout from module A using tag. When I'm trying to access the databinding of included layout, it return View object instead of ViewDataBinding
However when I'm trying to continue to access the id inside the included layout, the compilation works fine even the IDE showing an error. I've tried rebuild project, invalidate cache and everything else.
And I'm sure already follow the rules how to implement DataBinding. This is the layout on the module app :
<layout xmlns:android="http://schemas.android.com/apk/res/android>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_gray"
android:orientation="vertical">
<include layout="@layout/included_layout" id="@+id/contact"/>
</LinearLayout>
</layout>
And the layout on module A :
<layout xmlns:android="http://schemas.android.com/apk/res/android>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</layout>