I have recently switched from using ButterKnife
to using android DataBinding
, but one of the classes fails to generate.
ActivityMainBindingImpl
< Generates fine.
But ActivityMainBinding
is missing and it also shows that it can't be found in the Impl class itself.
I have tried everything you can find on the internet through multiple search engines so far. (invalidate caches rebuilding updating etc.) Maybe this is a bit more niche and I hope some of you guys have encountered it before?
I do have
dataBinding {
enabled = true
}
Important to note I am using androidx instead of the old support libraries.
It might be silently failing somewhere but I have tried it with and without any <data>
elements in my layout file.
I also wrap my layout correctly with <layout>
like so:
<layout 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">
It seems rather odd it can generate the Impl class fine, but the other doesn't exist.
I have gone into the folder where it is generated as well and only the Impl class is visible.
Full XML layout
<?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"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.activities.MainActivity"
tools:layout_editor_absoluteY="25dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/toolbar_container_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ScrollView
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar_container_layout">
<!-- This is a comment #001C40 -->
<LinearLayout
android:id="@+id/scroll_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/dashboard"
android:layout_width="match_parent"
android:layout_height="700dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar_container_layout">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/dashboard_header"
android:layout_width="0dp"
android:layout_height="100dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/logo_container"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/facta_logo"
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/facta_logo" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.gridlayout.widget.GridLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:horizontalSpacing="16dp"
android:verticalSpacing="16dp"
app:columnCount="2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/dashboard_header"
app:rowCount="4">
<include layout="@layout/dashboard_card" />
<include layout="@layout/dashboard_card" />
<include layout="@layout/dashboard_card" />
<include layout="@layout/dashboard_card" />
<include layout="@layout/dashboard_card" />
<include layout="@layout/dashboard_card" />
</androidx.gridlayout.widget.GridLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
The error is
Cannot resolve symbol 'ActivityMainBinding'
Where my XML layout is activity_main.xml