【发布时间】:2018-04-21 09:26:34
【问题描述】:
有没有人成功使用 Room over Android 多模块 Kotlin 设置。
@Entity
data class School(@Embedded val student: Student)
data class Student(val age: Int = 0)
只要我在主模块中有以上两个类,一切都会正确编译。
但是,如果我将 Student 类移动到另一个 android 库模块和主模块中的 School。它抛出编译时错误:
error: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).
Tried the following constructors but they failed to match:
Student(int) : [arg0 : null]
注意:在调试时发现这可能是name mangling 问题。如果我将 Student 类更改为 data class Student(val arg0: Int = 0) 它编译得很好。
看起来在编译时 age 暴露为 arg0
知道如何解决这个问题吗?
【问题讨论】:
标签: android android-room android-architecture-components