无法为课程创建转换器 [英] Unable to create converter for class
本文介绍了无法为课程创建转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用程序和Gson转换器中使用JSON进行翻新.如果没有互联网连接,我想使用数据库.我决定使用Sugar ORM.
但我得到一个IllegalArgumentException
.
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:无法为类
java.lang.IllegalArgumentException: Unable to create converter for class
这是我的对象
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
推荐答案
问题是使用Sugar时您的类中不能有名为id
的变量,因为默认情况下它使用自己的内部ID.尝试重命名为userId
或类似名称.
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.
这篇关于无法为课程创建转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文