我是android架構組件中的新成員。我正在嘗試與android-architecture-components/BasicRxJavaSample以及Gradle配置一起構建應用程序。但我得到以下錯誤:錯誤:實體和Pojos必須有一個可用的公共構造函數,並且無法找到字段的設置器
- 錯誤:(14,8)錯誤:實體和Pojos必須有一個可用的公共構造函數。你可以有一個空的構造函數或者一個構造函數,它們的參數匹配字段(通過名稱和類型)。嘗試使用下列構造函數,但它們不匹配:= Department(java.lang.String,java.lang.String):[id: null,dep:null]
- 錯誤:(16,20)錯誤:無法找到字段的setter。
- 錯誤:(18,20)錯誤:無法找到字段的setter。
我對所有體系結構組件使用「1.0.0-alpha9」版本。我也嘗試過使用當前的「1.0.0-beta1」版本。
我看了[曖昧的getter for Field ...房間持久性庫 2鏈接也可以根據谷歌示例不需要爲每個字段設置。
Model類
@Entity(tableName = "tblDepartment")
public class Department{
@PrimaryKey
private String mId;
private String mName;
@Ignore
public Department(String dep) {
mId= UUID.randomUUID().toString();
mName= dep;
}
public Department(String id, String dep) {
mId = id;
mName=dep;
}
public String getDepartmentId() {
return mId;
}
public String getDepartmentName() {
return mName;
}
}
你的問題是與'Expense'類。你的問題顯示了一個'部門'類。要麼你有錯誤的錯誤信息或錯誤的代碼。 – CommonsWare
我錯誤地添加了錯誤的錯誤日誌。 –