My project contains multiple modules, and I am using aar files of other modules contains custom views and components. so I have an XML in .aar and I want to use it in my project.
Of course, I can but DataBinding doesn't generate it in the generated file, so I don't have access to XML's components and widgets.
My fragment's XML is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- Comes from AAR file -->
<include
android:id="@+id/toolbarLayout"
layout="@layout/simple_tool_bar" />
Simple toolbar is:
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/simple_tool_bar_height"
app:elevation="0dp">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:navigationIcon="?attr/homeAsUpIndicator"
app:navigationIconTint="@color/primary" />
</com.google.android.material.appbar.AppBarLayout>
And Databinding generated file is:
public abstract class FragmentTestBinding extends ViewDataBinding {
@NonNull
public final View toolbarLayout;
So as you can see in the generated file toolbarLayout is an instance of View but it should be SimpleToolBarBinding.
When you are working on a project that contains modules instead of .aar it everything is working well, but after generating the .aar file and use it in another project it doesn't.