I'm getting this error on this piece of code. You must annotate primary keys with @NonNull. "uidString" is nullable.
When I annotate it with @NonNull and @PrimaryKey, An entity must have at least 1 field annotated with @PrimaryKey
What's up?
import androidx.annotation.NonNull;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import java.util.UUID;
@Entity(tableName = "player_profiles")
public class PlayerGameProfile implements Parcelable {
@PrimaryKey
public String uidString = UUID.randomUUID().toString();
@ColumnInfo(name = "name")
public String name;
For Java you should annotate with @android.support.annotation.NonNull
Delete the other NonNull import you are using yet and change it to
import android.support.annotation.NonNull;
Then use both annotations
@PrimaryKey
@NonNull
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With