I am trying to add a database to my Android app through the Room Persistence library. At compilation a get the above error. In addition Room can't find my getters, although i can clearly see all of them in my code.
Here's my code for the entity:
@Entity(tableName = "users", indices = @Index(value = "username", unique = true))
public class User {
@NonNull
public String getuId() {
return uId;
}
public void setuId(@NonNull String uId) {
this.uId = uId;
}
public String getuUsername() {
return uUsername;
}
public void setuUsername(String uUsername) {
this.uUsername = uUsername;
}
@NonNull
public String getuPassword() {
return uPassword;
}
public void setuPassword(@NonNull String uPassword) {
this.uPassword = uPassword;
}
public String getuEmail() {
return uEmail;
}
public void setuEmail(String uEmail) {
this.uEmail = uEmail;
}
@NonNull
@PrimaryKey
@ColumnInfo(name = "user_id")
private String uId;
@ColumnInfo(name = "username")
private String uUsername;
@NonNull
@ColumnInfo(name = "password")
private String uPassword;
@ColumnInfo(name = "email")
private String uEmail;
@Ignore
public User(String userName, String email, String password){
uId = UUID.randomUUID().toString();
uUsername = userName;
uEmail = email;
uPassword = password;
}
public User(@NonNull String id, String username, String email,@NonNull String password){
this.uId = id;
this.uUsername = username;
this.uPassword = password;
this.uEmail = email;
}
}
And the error i get:
Error:(14, 8) error: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type). Tried the following constructors but they failed to match: User(java.lang.String,java.lang.String,java.lang.String,java.lang.String) : [id : null, username : null, email : null, password : null]
Also this:
Error:(53, 20) error: Cannot find getter for field. Error:(56, 20) error: Cannot find getter for field. Error:(60, 20) error: Cannot find getter for field. Error:(63, 20) error: Cannot find getter for field.