I am using view binding and to do so I used the following code.
buildFeatures{ viewBinding true }
And I got this error:
> [databinding] {"msg":"Found \u003clayout\u003e but data binding is not
> enabled.\n\nAdd buildFeatures.dataBinding \u003d true to your
> build.gradle to enable
> it.","file":"C:\\Users\\akash\\AndroidStudioProjects\\NavigationSafeArgs\\app\\src\\main\\res\\layout\\fragment_home.xml","pos":[]}
After reading the thrown error I thought It is saying to enable dataBinding So I added dataBinding true too inside buildFeatures. Still It throws the same error.
Here is my fragment_home.xml code;
<?xml version="1.0" encoding="utf-8"?>
<layout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".HomeFragment">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/home_screen"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<Button
android:id="@+id/button_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/login" />
</LinearLayout>
</layout>
Enabling dataBinding and viewBinding together solved my problem.
buildFeatures {
viewBinding true
dataBinding true
}
I also added kotlin-kapt into plugins
plugins {
id 'kotlin-kapt'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With