Fixed
Status Update
Comments
yb...@google.com <yb...@google.com> #2
I should probably elaborate on that a bit more here :P. The ideal case would be that data classes written in other modules work the same when consumed. A standard data class (no secondary constructors, `val` properties) works fine when in the same module. The errors produced are also pretty confusing. They'll usually give what they read from the bytecode (constructor params called "var0" or the like) and reports missing setters for fields without names of said fields.
ak...@gmail.com <ak...@gmail.com> #3
I can confirm the bug and the workaround. The same problem arises when you use a data-class from a library with @Embedded
yb...@google.com <yb...@google.com>
ak...@gmail.com <ak...@gmail.com> #5
given that log, looks like kotlin again not generating proper parameter names for methods.
Description
Version used: 1.0.0-beta1
Kotlin 1.1.51
Gradle 3.0.0-beta6
Devices/Android versions reproduced on: Nexus 5 - Android Marshmallow (6.0.1)
The model (data) class:
@Entity(tableName = "class")
data class Class(
@PrimaryKey
var id: Long = 0,
var class_name: String = "")
Room fails in this case due to multiple constructors and suggests to use @Ignore. I'm not sure it's not picking the default constructor.
There are few workarounds for this problem:
1. Use @Ignore as suggested by Room.
2. Somehow it picks the appropriate constructor in this case:
@Entity(tableName = "class")
data class Class(
@PrimaryKey
var id: Long,
var class_name: String = "")
3. Switch to deprecated kapt.generateStubs = true. Instead of using apply plugin: 'kotlin-kapt'.
I wish Room could pick up automatically the default no-arg constructor and in case it doesn't then show error and then developer can either use @Ignore or the new annotation to select default constructor.