Sagar Khurana
04/23/2026, 12:07 PMIncompatibleClassChangeError on $stable when kotlinx-serialisation tries to deserialize plain DTO classes at runtime:
java.lang.IncompatibleClassChangeError:
Expected 'int food.boo.bar.data.remote.dto.CategoryDto.$stable'
to be a instance field rather than a static field
at CategoryRepository.getCategories(CategoryRepository.kt:47)
The offending class is completely vanilla — no Compose annotations, no custom serializers:
@Serializable
data class CategoryDto(
val id: Int,
val name: String
)
Reproduces across three different toolchain combos:
Kotlin 2.4.0-Beta2 + Compose MP 1.10.3 + KSP 2.3.7
Kotlin 2.3.21 + Compose MP 1.10.3 + KSP 2.3.7
Kotlin 2.3.10 + Compose MP 1.10.1 + KSP 2.3.6
Other context:
• This is a debug build — no R8, minification is disabled, so it's not a shrinking artifact
• The Compose compiler plugin is applied to the whole app module with no stability configuration, so it's instrumenting every class in commonMain, including these plain DTOs
• The crash only fires during deserialization (construction via the serialization-generated factory), not when constructing the DTO manually
Is this a known interaction between the Compose compiler plugin and the kotlinx-serialization plugin's generated constructor code? Any idea what changed recently that could cause $stable to land as a static field when the serialization-generated init path runs? Happy to file a YouTrack issue with a reproducer if helpful.Asapha
04/23/2026, 12:11 PMSagar Khurana
04/23/2026, 12:12 PMAsapha
04/23/2026, 12:12 PMSagar Khurana
04/23/2026, 12:13 PMAsapha
04/23/2026, 12:15 PMplugins {
[…]
alias(libs.plugins.kotlinSerialization)
alias(libs.plugins.composeCompiler)
}Sagar Khurana
04/23/2026, 12:22 PMSagar Khurana
04/23/2026, 12:38 PMkotlinSerialization to apply before composeCompiler in the plugins {} block of my composeApp/build.gradle.kts, did a clean install, and the IncompatibleClassChangeError
Confirming on Kotlin 2.3.21 + Compose MP 1.10.3 + KSP 2.3.7
@Asapha thanks, god may bless you