Open mtrakal opened 9 months ago
it happens only in some build cases, but 100% reproducible while run ./gradlew clean assembleDebug --no-build-cache --no-daemon
Configuring room to generate kotlin seems to fix this issue for me.
android { ... ksp { arg("room.generateKotlin", "true") } }
edit: sorry I missed that the author had this already enabled.
Configuring room to generate kotlin seems to fix this issue for me.
android { ... ksp { arg("room.generateKotlin", "true") } }
It does not, and in fact the author of the issue have this option enabled too.
I have exactly the same issue and can confirm it's not 100% reproducible. I was using value class just fine in my Room code, but at some point in time suddently I started to get this error.
Calling build with ./gradlew clean assembleDebug --no-build-cache --no-daemon
sometimes allows the issue to go away, but most of the times it does not.
FWIW I have a
kotlin = "1.9.22"
kspPlugin = "1.9.22-1.0.17"
room = "2.6.1"
and in my build I have
ksp {
arg("room.generateKotlin", "true")
}
Writing a converter for your value type resolves the issues.
@JvmInline
value class ArticleId(val id: String)
class IdConverter {
@TypeConverter
fun toArticleId(value: String?): ArticleId? = value?.let(::ArticleId)
@TypeConverter
fun toString(value: ArticleId?): String? = value?.id
}
I'm getting the same compilation error myself. I haven't yet been able to figure out what part of my code is causing it, and there seem to be no working answers when searching for it.
kotlin = "1.9.22"
kspPlugin = "1.9.22-1.0.17"
room = "2.6.1"
Edit: Turns out this was caused by me trying to save a LocalTime object to the database, which I had implemented a type converter for, but I had accidentally added the type converters to my DAO and not my database class... After changing that, the issue was resolved :)
My situation was very similar to yours, it was fixed when I moved the const out of the value class.
For you, you can try moving private const val AMOUNT_MOVE_POINT_BY = 2 // FIXME!!!
out, as a top level const.
@Leojangh we have, of course, moved it outside of value class
to some Constants class. As I described in first comment, I know what exactly caused the issue and how to workaroundi it :), but it's still the valid KSP issue.
We don't use top level constants if it's not needed (and I don't see any reason have specific constant as global/top level) :)
Configuring room to generate kotlin seems to fix this issue for me.
android { ... ksp { arg("room.generateKotlin", "true") } }
edit: sorry I missed that the author had this already enabled.
me too, but to the author no, he said it in the post
@Leojangh we have, of course, moved it outside of
value class
to some Constants class. As I described in first comment, I know what exactly caused the issue and how to workaroundi it :), but it's still the valid KSP issue.We don't use top level constants if it's not needed (and I don't see any reason have specific constant as global/top level) :)
What about native value classes like kotlin.time.Duration? I can't do that and facing the OP issue
room database don't store float type data
Why did this happen? Because we use
value class
which is stored to room.versions tested:
and
The
private const val AMOUNT_MOVE_POINT_BY = 2
cause, that KSP failed with a weird error. When line is commented or removed, app/KSP build is a success.Having another
fun
s incompanion object
is not problem. Onlyval
is.private val AMOUNT_MOVE_POINT_BY = 2
is not OK as well.Move variable on top (before functions) but still in companion object causes the same problem (so not relevant to ordering).