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”
  • “Do.007” (2) – Use Github for version management
  • “Do.008” (3) — Git branch management model
  • “Do.009” combat (4) – AndroidStudio plugin recommended
  • “Do.014” Combat (5) – Gradle configuration Release is separated from debug environment

other

  • “Do.016” 图 文 Win Computer Download Tencent Video mp4
  • How to use Windows computer efficiently with “DO.017”?
  • Is “DO.018” necessary for private work?
  • “Do.019” 2018 — Year-end summary
  • How should a “DO.020” programmer survive the winter
  • “Do.021” for all updates to AndroidStudio3.4