微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Room AppDatabase_Impl.onValidateSchema错误

如何解决Room AppDatabase_Impl.onValidateSchema错误

尝试使用Kotlin在Android(测试运行器Robolectric)上使用真实数据库(而非模拟)测试存储库时,出现一个奇怪的错误。 在真实设备和模拟器上运行/调试应用程序都很好-没有任何错误

问题发生在这里

_infoTerm

_existingTerm

因此比较失败,因为primaryKeyPostions不同。但是,为什么它们在测试中有所不同,而在真实设备/仿真器中却如此?

该实体看起来像这样:

════════ Exception caught by animation library ═════════════════════════════════
The following FormatException was thrown while notifying status listeners for AnimationController:
Trying to read MM from 20200814 at position 8

When the exception was thrown,this was the stack
#0      _DateFormatField.throwFormatException 
package:intl/…/intl/date_format_field.dart:87
#1      _DateFormatPatternField.parseField 
package:intl/…/intl/date_format_field.dart:337
#2      _DateFormatPatternField.parse 
package:intl/…/intl/date_format_field.dart:250```

sqlLite中,使用以下代码段创建了表:

@Entity(
    tableName = "term",primaryKeys = ["id","language"],indices = [Index("id"),Index("language")]
)
data class Term(
    @ColumnInfo(name = "id")
    var termId: Int = 0,val language: String = "en",@ColumnInfo(name = "value")
    var value: String = ""
)

更新:如果我将主键设置为非复合键,则所有位置都可以正常工作。但是我确实需要一个复合主键...

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。