Cannot find setter for field - using Kotlin with Room database : <p>I'm integrating with the Room persistence library. I have a data class in Kotlin like:</p>

<pre><code>@Entity(tableName = "story")
data class Story (
        @PrimaryKey val id: Long,
        val by: String,
        val descendants: Int,
        val score: Int,
        val time: Long,
        val title: String,
        val type: String,
        val url: String
)
</code></pre>

<p>The <code>@Entity</code> and <code>@PrimaryKey</code> annotations are for the Room library. When I try to build, it is failing with error:</p>

<pre><code>Error:Cannot find setter for field.
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
&gt; Compilation failed; see the compiler error output for details.
</code></pre>

<p>I also tried providing a default constructor:</p>

<pre><code>@Entity(tableName = "story")
data class Story (
        @PrimaryKey val id: Long,
        val by: String,
        val descendants: Int,
        val score: Int,
        val time: Long,
        val title: String,
        val type: String,
        val url: String
) {
    constructor() : this(0, "", 0, 0, 0, "", "", "")
}
</code></pre>

<p>But this doesn't work as well. A thing to note is that it works if I convert this Kotlin class into a Java class with getters and setters. Any help is appreciated!</p>
