Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve lint warning "field is never used" but it is serialized

Tags:

java

android

lint

I have a small class in my Android project containing some variables, I assign them in the constructor.

I then serialize the object to json using the Gson library and the function String Gson::toJson(Object src)

How can I solve this lint warning : "private field is assigned but never accessed" on these variables? Is there a special comment for that case?

edit : sorry there is another warning too "Field can be converted to a local variable" which is wrong!

Thank you!

like image 518
iteal Avatar asked Dec 11 '22 19:12

iteal


1 Answers

You can add @SuppressWarnings("unused") annotation on field which will prevent generating such messages.

like image 113
k0ner Avatar answered Feb 16 '23 04:02

k0ner