View Binding not work with "Include": incompatible types: ProgressBarLayoutBinding cannot be converted to ViewDataBinding
I found solution.If outer xml is data binding xml, then inner xml also must be data binding.So progress_bar_layout.xml
must 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"> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/containerProgressBarLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#66545a5a" android:clickable="true" android:elevation="2dp" android:focusable="true"> <ProgressBar android:id="@+id/progressBar" style="?android:attr/progressBarStyle" android:layout_width="@dimen/min_height" android:layout_height="@dimen/min_height" android:indeterminateTint="@color/colorPrimary" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> </androidx.constraintlayout.widget.ConstraintLayout></layout>
In progress_bar_layout use below line (m also not sure it works for you or not because I didn't try yet but if it works then I will add more clarification)
Maybe this error is for combining view binding and data binding. View binding doesn't support layout variables
<androidx.constraintlayout.widget.ConstraintLayout ... tools:viewBindingIgnore="true" >...</androidx.constraintlayout.widget.ConstraintLayout>
In addition of the existing answers. If your layout uses layout (data-binding) tag as parent, then you have to wrap your include's layout inside layout (data-binding) tag. Below are the source code.
include's Layout
<layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"> <matrixsystems.core.widgets.CustomToolbar android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/app_white" android:fitsSystemWindows="true" android:minHeight="?attr/actionBarSize" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /></layout>
Layout
<include android:id="@+id/toolbar" layout="@layout/toolbar_app" />
Activity
override fun onCreate(savedInstanceState: Bundle?) { // getting toolbar from binding setSupportActionBar(binding.toolbar.root as Toolbar)}