I am using Android Studio 2.0 Preview 4. I\'m using Android SDK tools 25 rc1. This error persists no matter how many times I clean / rebuild project. File->Invalidate Caches
I'm also getting the same problem after Migrating my existing project to AndroidX and i solve it by doing below things
Build -> Clean Project
Build -> Rebuild Project
After that
File -> Invalidate Caches/Restart...
After migrating to AndoridX, You need to remove old v4 or v7 widgets from the XMl .For ex - you need to replace if you are using some AppCompat widget like
<android.support.v7.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11sp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:tag="showMore"/>
Replace it with andoridx widget
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/txt_summary_desc_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11sp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="Read More"/>
Worked well for me.
One of the quickest hack i use is rename the xml file back and to.
e.g.
rename abc_layout.xml
to abc_layout2.xml
. once the binding import shows error rename it back to abc_layout.xml
.
the short cut to rename is shift + F6
. its way quicker that entire project rebuild. this will only remove error from one file though.
Delete module level build
folder and re-open your project.
By default, a Binding
class will be generated based on the name of the layout file, converting it to Pascal case and suffixing "Binding" to it. The above layout file was main_activity.xml so the generate class was MainActivityBinding. The problem is you are trying to create binding class manually.
This class holds all the bindings from the layout properties (e.g. the user variable) to the layout's Views
and knows how to assign values for the binding expressions. The easiest means for creating the bindings is to do it while inflating.
No need to restart the Android Studio.
Just try to Invalidate caches/Restart from File. This worked for me.