I have class A, that extends class B, that implements Serializable.
When i try to transform it in a JSON, using GSON lib, it says that "class declares multiple JSON fields named serialVersionUid".
As long as i know, if i don't explicit declare serialVersionUid, it is generated by GSON.
I also tried to put serialVersionUid statically, but doesn't work.
I can fix the error by implementing Serialization in class A, but i have many classes that extends B, and i don't think exclude B from them will be a good ideia…
Does anyone know why this error occurs?
Class A extends B {
private c;
private d;
private e;
}
Class B extends Serializable{
private f;
private g;
}
Best Answer
EDITED:
We've changed the code there to use GSON with a customised GsonBuilder class. The code is looking a little bit like that:
In this case, we're ignoring the serialVersionUID and the CREATOR fields when jsonizing it.
OLD:
I had the same issue some seconds ago. I've solved it by adding serialVersionUUID using the transient modifier. to by superclass, like that:
I hope it helps you too.