Reputation: 436
I am writing Android application using DataBinding by referencing https://developer.android.com/topic/libraries/data-binding/index.html.
But while building my project, It is showing an error in generated class as
> '/databinding/DataBinderMapper.java:10: error: constant expression
> required.'
This error is happening in switch statement inside generated class DataBinderMapper.java (This file is an auto generated file for databinding)
Any one knows the reason for this java switch case error happening in Auto generated buld file?
Edits: I found the reason for this issue is, layout reference created in R.java file is not final for this case. For example, in my case layout reference in R.java is
public static int activity_main=0x7f04001c;
Actually it should be
public static final int activity_main=0x7f04001b;
But I don't know the reason for this happened and how to change it to final.
Upvotes: 2
Views: 728
Reputation: 810
This error happens when your project has dependency with library or external plugin apart from application. The reason for this issue is, the ids generated might clash when you have dependency with multiple library/ plugins.
Upvotes: 1
Reputation: 18276
Probably your model that you are binding against has final modifiers in its variables.
Upvotes: 1