I am writing an Android application using DataBinding, referring to https://developer.android.com/topic/libraries/data-binding/index.html .
But when creating my project, it shows an error in the generated class as
> '/databinding/DataBinderMapper.java:10: error: constant expression
> required.'
This error occurs in the switch statement inside the generated DataBinderMapper.java class (this file is an automatically generated file for data binding)
Does anyone know the cause of this error in a java switch event in an automatically generated buld file?
edits:
I found the cause of this problem, the link to the layout created in the R.java file is not final for this case. For example, in my case, a layout link in R.java
public static int activity_main=0x7f04001c;
In fact, it should be
public static final int activity_main=0x7f04001b;
But I do not know why this happened and how to change it to final.
source
share