Attempt to recreate a file for type io.realm.RealmStringRealmProxyInterface

問題產生的情形:

當使用Realm數據庫的時候,實現了兩個繼承RealmObject的同名子類,放在不同的包路徑下,編譯運行報如下錯誤:

Attempt to recreate a file for type io.realm.RealmStringRealmProxyInterface

實現的同名不同路徑的類:

public class RealmString extends RealmObject  implements Serializable {

    @PrimaryKey
    public String string;

    public RealmString() {
    }

    public RealmString(String string) {
        this.string = string;
    }

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }
}

異常產生的原因:

 

解決方案:

在應用內只保留一個繼承自RealmObject的類即可。

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章