Playing databinding today, after everything is done, make a moudle, and an exception is reported:
Error:Execution failed for task ':DataBindingDemo:compileDebugJavaWithJavac'.
> java.lang.RuntimeException: Found data binding errors.
****/ data binding error ****msg:Identifiers must have user defined types from the XML file. Color is missing it
file:D:\Android\AndroidProject\Android5.0Demo\DataBindingDemo\src\main\res\layout\activity_resource.xml
loc:120:45 - 120:49
****\ data binding error ****
The main content extracted is
Identifiers must have user defined types from the XML file. View is missing
It means that the id is not defined in the layout file, so I wonder what the id is? Later, after passing through Baidu, only one Chinese blog mentioned this problem and it was deleted. However, I still found the content of the post from the Baidu snapshot, and said yes, some packages in the <data> tag were not imported, so I reported this abnormal.
After looking at my layout carefully, I found the following settings:
<CheckBox
android:id="@+id/cb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:button="@drawable/checfbox_selector"
android:checked="@{fileBean.isChecked ? true : false}"
android:visibility='@{fileBean.isDirectory ? View.INVISIBLE : View.VISIBLE}'
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
I use databinding to make judgments in this checkBox to show or hide this checkBox, but it does not introduce View objects.
Later added:
<import type="android.view.View" />
The problem is solved!