ฉันได้รับข้อผิดพลาดนี้ในโค้ดชิ้นนี้ 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;
When I annotate it with @NonNull, An entity must have at least 1 field annotated with @PrimaryKey
คุณใส่คำอธิบายประกอบด้วย ทั้งสอง หรือแค่@NonNull
- person tkausl   schedule 13.11.2019import android.support.annotation.NonNull;
- person Tiberiu Zulean   schedule 13.11.2019implementation 'androidx.room:room-runtime:2.2.1'
และannotationProcessor 'androidx.room:room-compiler:2.2.1'
ฉันเจอสิ่งที่ดูเหมือนจะเป็นปัญหาเดียวกันกับห้องสมุดรุ่นก่อน ๆ - person MikeT   schedule 13.11.2019