如何正确注释作为 Room 实体中主键一部分的对象变量?

How to properly annotate object variables that are part of primary key in Room entity?

我收到一个错误:"You must annotate primary keys with @NonNull. "name" 可以为空。"

我不明白这个错误的来源是什么,因为我非常清楚地用 @NonNull 注释我的字符串变量 "name",它被声明为复合主键的一部分。我是否错误地设置了复合主键?

@Entity(tableName = "ScavItems",
        primaryKeys = { "scavHuntID", "name" },
        foreignKeys = {
                @ForeignKey(entity = ScavHunt.class,
                        parentColumns = "shID",
                        childColumns = "scavHuntID")
        })
public class ScavItem {
    @NonNull private int scavHuntID;
    @NonNull private String name;

    @ColumnInfo(name = "found")
    private boolean found;

    public ScavItem(int scavHuntID, String name){
        this.scavHuntID = scavHuntID;
        this.name = name;
        found = false;
    }

    public String getName(){ return this.name; }
    public boolean getFound(){ return this.found; }
    public int getScavHuntID(){ return this.scavHuntID; }
    public void setFound(boolean found){ this.found = found; }
}

我明白了。我正在导入不正确的 NonNull 包。 这是正确的导入:

import android.support.annotation.NonNull;