Remember that Mvvm introduces classes that call static methods and variables in XML in the wrong way
January 25, 2024
by Nina Butcher
No Comments
An error phenomenon
Error: always generate a view binders Java. Lang. ClassCastException: android.databinding.tool.expr.IdentifierExpr cannot be cast to android.databinding.tool.expr.StaticIdentifierExprCopy the code
Translate:
Unable to generate view binder, reporting type conversion exception: Android. Databinding. Tool. Expr. IdentifierExpr types cannot be converted to android. The databinding. Tool. Expr. StaticIdentifierExpr type An identity reference type cannot be converted to a static identity reference type.
Error cause:
View.VISIBLE View.GONE <variable/>
<variable
name="View"type="android.view.View" />
Copy the code
Fix code:
<import type="android.view.View"/>
Copy the code
The lines
This is a minor problem that can be easily detected if it happens to common classes such as Views and TextUtils, but can be a bit more difficult if it happens to custom utility classes. So here is a record, so that when you encounter the same error, you can also quickly search for the corresponding solution through search hospitality.
Recommended reading
series
“Do.006” Actual Combat (1) — I want to say “Do it”