本文介绍了Android Room库错误:找不到字段的设置器. (科特琳)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用房间图书馆,并且有以下提到的实体:
I am using room library and I have below mentioned entity:
@Parcelize
@Entity(tableName = "tb_option")
data class OptionsTable(
var question_id: Int? = null,
var option_id: Int? = null,
var option: String? = null,
var is_selected: Int? = null,
@PrimaryKey(autoGenerate = true)
var sr_no: Int = 0) : Parcelable
如您所见,我将所有字段声明为var
,但仍显示错误为:
as you can see I have all the field declared as var
but it is still showing error as:
error: Cannot find setter for field.
e:
e: private java.lang.Integer is_selected;
e:
^
请为此提出一些解决方案.
please suggest some fix for this.
谢谢
推荐答案
我从
@PrimaryKey(autoGenerate = true)
var sr_no: Int = 0
,最后的代码是:
@PrimaryKey(autoGenerate = true)
var sr_no: Int
为我工作,因为它是一个自动生成的字段.
worked for me because it was an auto-generated field.
这篇关于Android Room库错误:找不到字段的设置器. (科特琳)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!