Describe the bug
This is a very weird bug that happened to me. Took me hours to figure it out. Basically, I'm getting an Unresolved reference: serializer error when trying to use it. The IDE is fine, there's no error. I can use the file but every time I compile, it's having an error. Now, all my configurations are good. I was able to use them normally until I introduced this normal data class. I restarted my IDE, doesn't work. Restart and Invalidate, still doesn't work. Clean, doesn't work. Rebuild, doesn't work, Clean, Rebuild, then restart and invalidate, still didn't work. And then I decided to move the file away to another folder. IT WORKED. I renamed it back and it didn't work again. I was thinking is there some sort of cache or something blocking it. If I'm missing something, please do point me in the right direction. Many thanks!
To Reproduce
I'm not able to reproduce it specifically.
Expected behavior
No Unresolved reference: serializer bug
Environment
Try to wipe out the gradle cache in your project. It seems likely that this is a problem with incremental compilation.
I didn't really do anything. Slept and tried it again today and it works. weird...
Next time it occurs, I'll try wiping the Gradle cache.
Probably stopping Kotlinc/Gradle daemon (or killall java 馃檭 ) may also help in overcoming incremental compilation glitches.
// gradle.properties
ktor_version=1.3.0-rc
kotlin.code.style=official
kotlin_version=1.3.60
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
apply plugin: 'kotlin'
apply plugin: 'application'
apply plugin: 'kotlinx-serialization'
...
implementation "io.ktor:ktor-serialization:$ktor_version"
And I hava a data class.
@Serializable
data class Version(val version: String)
When kotlin_version=1.3.60, after the build the compiled file is like the below.
@kotlinx.serialization.Serializable public final data class Version public constructor(version: kotlin.String) {
public final val version: kotlin.String /* compiled code */
public final operator fun component1(): kotlin.String { /* compiled code */ }
}
When kotlin_version=1.3.50, the complied file.
@kotlinx.serialization.Serializable public final data class Version public constructor(version: kotlin.String) {
public companion object {
}
@kotlin.Deprecated public constructor(seen1: kotlin.Int, version: kotlin.String?, serializationConstructorMarker: kotlinx.serialization.SerializationConstructorMarker?) { /* compiled code */ }
public final val version: kotlin.String /* compiled code */
public final operator fun component1(): kotlin.String { /* compiled code */ }
@kotlin.Deprecated public object `$serializer` : kotlinx.serialization.internal.GeneratedSerializer<com.walmart.rxeligibilityrules.data.model.Version> {
}
}
Any idea what's difference b/w 1.3.50 and 1.3.60 would cause the issue?
Any guideline to debug this @sandwwraith ?
@haohcraft AFAIR, There were not any specific changes in this place between 1.3.50 and 1.3.60. Check all libraries versions for consistency, do a clean rebuild, try to remove gradle daemons and build cache, etc, etc. If the problem is so stable reproducible, please open a new ticket with your/sample project attached.
Most helpful comment
Probably stopping Kotlinc/Gradle daemon (or
killall java馃檭 ) may also help in overcoming incremental compilation glitches.