Lib Gdx json serializationexception and missing no-arg constructor-Collection of common programming errors
The exception message “Class cannot be created (missing no-arg constructor): com.bvo.easyBim.Model.Cursor” describes exactly what is going wrong.
The Libgdx JSON code uses reflection to create instances of objects and initialize them. In your example, there must be a com.bvo.easyBim.Model.Cursor
in the saved JSON file. So when reading that file, the JSON code needs to create an instance of a Cursor
to put the data in. It assumes there is a no-argument constructor that it can use to create an empty Cursor
(it cannot figure out which constructor would be appropriate otherwise). However, it seems that there is no such method.
You will either have to add a no-argument constructor to Cursor
, or you will have to add a custom serializer (see https://code.google.com/p/libgdx/wiki/JsonParsing#Customizing_serialization) that knows how to save a Cursor
instance and knows the appropriate constructor to invoke when reading a Cursor
back in.