Problem:
I'm working on a project having dataBinding integrated now whenever I create a new layout or add a view to an existing one it just not appear in binding object and I even try rebuilding and cleaning the project but it doesn't work and I have to just restart the project or rename the layout file one or two times to update the BindingClass. It is so annoying and consuming my important time.
Code
build.grade
dataBinding {
enabled = true
}
layout_file
<?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">
<RelativeLayout
android:id="@+id/lyt_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View android:id="@+id/old_view_1" .../>
<View android:id="@+id/old_view_2" .../>
<!-- New View -->
<View android:id="@+id/new_view" .../>
</RelativeLayout>
</layout>
Activity/Fragment/Place where layout is used
LayoutFileBinding binding = DataBindingUtil.setContentView(this, R.layout.layout_file);
binding.newView
// here I get error cannot resolve (newView) until i restart project or rename layout file