Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not remove generated DataBinding code

Tags:

I used DataBinding in one of my classes CardRecicleViewAdapterTech.class , but I imported a library which does not support DataBinding and I switched to butter knifefor that class. The problem is that when I run the project, Android Studio always generates a class binding related with CardRecicleViewAdapterTech.class and this causes a crash. The generated class is:

CardViewTechBinding.java

I have deleted that java file in Android Studio databinding folder, but its generated again and again even when I do not use databinding anymore in my xml or my class.

This is my layout where I do not using dataBinding

card_view_tech.xml

so that generate CardViewTechBinding.java even when I am not using dataBinding

<?xml version="1.0" encoding="utf-8"?>

<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:ProgressWheel="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_tech"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:layout_gravity="center"
        android:layout_marginTop="@dimen/standard_margin"
        android:layout_marginLeft="@dimen/standard_margin"
        android:layout_marginRight="@dimen/standard_margin"
        card_view:cardCornerRadius="4dp"
        card_view:cardBackgroundColor="@color/primary_light">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <TextView
                android:text="TextView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/text_view_technologie_name" />

            <com.pro.soft.apppresentation.ProgressWheel
                android:id="@+id/pw_spinner"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_centerInParent="true"
                ProgressWheel:pwText="Authenticating..."
                ProgressWheel:pwTextColor="#222"
                ProgressWheel:pwTextSize="14sp"
                ProgressWheel:pwRimColor="#330097D6"
                ProgressWheel:pwBarLength="60dp"
                ProgressWheel:pwBarColor="#0097D6"
                ProgressWheel:pwBarWidth="5dp"
                ProgressWheel:pwRimWidth="2dp" />
        </LinearLayout>

    </android.support.v7.widget.CardView>

I tried to restart my Pc and Invalidate cache and restart Android Studio but without success. Please help.

like image 272
JoCuTo Avatar asked Dec 23 '16 14:12

JoCuTo


People also ask

Is Android DataBinding deprecated?

Recently Android has announced that with Kotlin 1.4. 20, their Android Kotlin Extensions Gradle plugin will be deprecated and will no longer be shipped in the future Kotlin releases. Android Kotlin Extensions plugin brought with it two very cool features : Synthetics let you replace calls to findViewById with kotlinx.

Can I use both DataBinding and Viewbinding?

View binding doesn't support layout variables or layout expressions, so it can't be used to declare dynamic UI content straight from XML layout files. View binding doesn't support two-way data binding.

Which is better Viewbinding and DataBinding?

The main advantages of viewbinding are speed and efficiency. It has a shorter build time because it avoids the overhead and performance issues associated with DataBinding due to annotation processors affecting DataBinding's build time.

Can not Resolve ActivityMainBinding?

I was getting the error "Can't resolve symbol ActivityMainBinding" after enabling dataBinding in build. gradle. After much trial and error, I figured out the solution was to exit / restart Android Studio. Works fine now.


Video Answer


2 Answers

In this order:

1.- Remove your file generated (build folder)
2.- Clean your project
3.- Invalidate cache and restart Android Studio
4.- Restart computer
like image 190
Jose Cuervas Avatar answered Oct 14 '22 16:10

Jose Cuervas


I had the same issue, and it was caused by having <layout> root tags in the XML. I did not realise that these tags were databinding related and the compiler also does not help you in this regard.

like image 38
Wyko Avatar answered Oct 14 '22 14:10

Wyko