Reputation: 21
Had anyone success with using Room over Android multi-module Kotlin setup.
@Entity
data class School(@Embedded val student: Student)
data class Student(val age: Int = 0)
Whenever I have both above classes in main module everything compiles properly.
But if I move the Student class to another android library module and School in main module. It throws compile time error as:
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]
Note: On debug found this might be name mangling issue. If I change the Student class to data class Student(val arg0: Int = 0)
it compiles fine.
Looks like at compile time age
exposed as arg0
Any idea how to resolve this issue?
Upvotes: 2
Views: 1140
Reputation: 515
I had the same issue. Entities and Room DAO placed in same module everything ok, putting entities in separate module break compilation. In my case the problem was putting enum declaration in same file as entity. Declaring enum in separate file solved the problem.
Upvotes: 1