我在这段代码中遇到了错误。You must annotate primary keys with @NonNull. "uidString" is nullable.
当我使用@NonNull和@PrimaryKey进行注释时,An entity must have at least 1 field annotated with @PrimaryKey
发生了什么问题?
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;
@NonNull
? - tkauslimport android.support.annotation.NonNull;
- Tiberiu Zuleanimplementation 'androidx.room:room-runtime:2.2.1'
和annotationProcessor 'androidx.room:room-compiler:2.2.1'
。我之前在早期的库中遇到了看起来相同的问题。 - MikeT