假设我们有一个GreenDao(版本3.2.2)实体。
@Entity
class Stats {
@Id
private Long id;
private int points;
private int fieldGoals;
private int per;
@Generated(hash = 608515378)
Stat(Long id, int points, int fieldGoals, int per) { ... }
... getter and setter here ...
}
稍后,我们决定将“每”字段的类型更改为“浮动”。 我们的班级变成这样:
@Entity
class Stats {
@Id
private Long id;
private int points;
private int fieldGoals;
private float per; // we changed 'int' to 'float'
@Generated(hash = 608515378)
Stat(Long id, int points, int fieldGoals, float per) { ... }
... getter and setter here ...
}
更改类型意味着更改表,更新架构。同样,这意味着我们需要在gradle中“升级”架构,这是我们所做的。 但是我们在gradle构建日志中遇到了这个错误:
Constructor (see Stat:9) has been changed after generation.
Please either mark it with @Keep annotation instead of @Generated to keep it
untouched, or use @Generated (without hash) to allow to replace it.
“状态:9”是带有“ @Generated(hash = 608515378)”注释的行。
我们如何解决这个问题?