Error: Cannot find setter for field, private final java.util.UUID id = null;

Hello,
Working through Chapter 11, I received the error message on building to run Criminal Intent on page 240 (to see the uploaded database items populating the app).

At this point, I am pretty far in the weeds and don’t even know where to start looking. I have pasted the error below and can paste any additional things that are needed. Thanks in advance!

I think this has to do with your Crime class not being set to be a “data” class.
I believe the benefit of the data keyword is that it does auto setters & getters.
My Crime class is defined like the following:

@Entity
data class Crime(@PrimaryKey val id: UUID = UUID.randomUUID(),
                 var title: String = "",
                 var date: Date = Date(),
                 var isSolved: Boolean = false)

Also notice that the Crime constructor automatically sets the UUID value.

I have the same error. Have you solved the problem?

UPD - solved the problem when changed → “val id” to “var id”, but I’m not sure it’s ok

1 Like