Unable to create converter for class

对着背影说爱祢 提交于 2019-12-24 07:06:10

问题


I am using retrofit in my app and Gson convertor for JSON. I would like to use database when there is not internet connection. I decided to use Sugar ORM. but I get an IllegalArgumentException.

java.lang.IllegalArgumentException: Unable to create converter for class

here is my object

public class User extends SugarRecord implements Parcelable {

    @SerializedName("id")
    @Expose
    private Integer id;
    @SerializedName("email")
    @Expose
    private String email;
    @SerializedName("name")
    @Expose
    private String name;
    @SerializedName("lastname")
    @Expose
    private String lastname;
    @SerializedName("properties")
    @Expose @Ignore
    private List<Object> properties = new ArrayList<>();
    @SerializedName("rights")
    @Expose @Ignore
    private String rights;
    @SerializedName("photo")
    @Expose
    private String photo;
    @SerializedName("favorites")
    @Expose @Ignore
    private List<PointsOnMap> favorites = new ArrayList<>();
    @SerializedName("token")
    @Expose
    private String token;

    public User() {
    }

    public User(String name, String lastname, String email, String photo, String token) {
        this.name = name;
        this.lastname = lastname;
        this.email = email;
        this.photo = photo;
        this.token = token;
    }
    //getters and setters

回答1:


Problem is you can't have a variable named id in your class when using Sugar since by default it uses its own internal ids. Try renaming to userId or something like that.



来源:https://stackoverflow.com/questions/39316707/unable-to-create-converter-for-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!