我尝试在 android kotlin 项目中实现 Room Persistent Database
库,但在编译时收到此警告。我不知道如何解决这场交战。
warning: There are multiple good constructors and Room will pick the no-arg constructor. You can use the @Ignore annotation to eliminate unwanted constructors.
自动生成类
public final class Gender {
^
Kotlin 数据类
import android.arch.persistence.room.Entity
import android.arch.persistence.room.PrimaryKey
@Entity
data class Gender(@PrimaryKey(autoGenerate = true)
var genderId: Int = 0,
var type: String = "")
最佳答案
我有同样的警告,我只是把 @Ignore 放在我的空构造函数之前
// Empty constructor
@Ignore
public Room_Database() {
}
关于android - 有多个好的构造函数,Room 会选择无参数构造函数。如何解决此警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52983393/