Fixed
Status Update
Comments
da...@google.com <da...@google.com> #2
A couple of questions:
1. Have you saw crash in real device or only in simulators?
2. Do you use dynamic feature for language ID?
1. Have you saw crash in real device or only in simulators?
2. Do you use dynamic feature for language ID?
ap...@google.com <ap...@google.com> #3
Tested on Android 12 Emulator with custom executor, but cannot repro this issue.
Description
Version used: 2.2.0-alpha01
Devices/Android versions reproduced on: Pixel 3 XL / Android P
I've tried to use the new awesome Target Entity feature that introduced at 2.2.0-alpha01.
But, I encountered the Room compiler error.
It seems to happen if try inserting immutable data class using @Insert(entity = ImmutableDataClass::class)
The error message says "Cannot find setter for field.". But, the generated Dao_Impl code does not use the setter methods.
Is this a Room compiler bug?
The workaround is replacing val to var.
Here is sample codes:
```
@Database(entities = [Project::class], version = 1)
abstract class TargetEntityDatabase : RoomDatabase() {
abstract fun projectDao(): ProjectDao
}
@Entity
data class Project(
@PrimaryKey
val id: Long,
val title: String,
@ColumnInfo(defaultValue = "''")
val longDescription: String
)
data class ProjectMiniApiEntity(
val id: Long,
val title: String
)
@Dao
interface ProjectDao {
@Insert(entity = Project::class)
fun insertNewProject(projectMini: ProjectMiniApiEntity)
}
```
Gradle logs:
```
> Task :app:kaptDebugKotlin FAILED
e: ProjectMiniApiEntity.java:20: error: Cannot find setter for field.
private final long id = 0L;
^
e: ProjectMiniApiEntity.java:22: error: Cannot find setter for field.
private final java.lang.String title = null;
^
```