Skip to content
Latchkey

kotlinx.serialization "plugin not applied" / serializer not found in CI

kotlinx.serialization relies on a compiler plugin that generates serializers for @Serializable classes at compile time. If the kotlin("plugin.serialization") plugin is not applied to a module, the runtime library is present but no serializer is generated, and CI fails at compile or at runtime.

What this error means

The build fails with "Serializer for class X is not found" or the compiler reports the serialization plugin is not applied, even though the runtime dependency is on the classpath.

Kotlin
e: /app/src/main/kotlin/Dto.kt: (5, 1): Serializable classes require the kotlinx-serialization
compiler plugin to be applied. Add id("org.jetbrains.kotlin.plugin.serialization").

Common causes

The serialization compiler plugin is not applied

Only the runtime library was added; without the plugin.serialization compiler plugin no serializer code is generated for @Serializable types.

The plugin is applied to the wrong module

In a multi-module build the plugin is missing from the module that actually declares the @Serializable classes.

How to fix it

Apply the serialization plugin and library

  1. Add kotlin("plugin.serialization") to the module with @Serializable types.
  2. Add the runtime kotlinx-serialization-json dependency.
  3. Rebuild so serializers are generated.
build.gradle.kts
plugins {
    kotlin("jvm") version "2.0.21"
    kotlin("plugin.serialization") version "2.0.21"
}
dependencies {
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
}

Apply the plugin in every module that needs it

Each module declaring serializable classes must apply the plugin; a shared convention plugin keeps this consistent.

How to prevent it

  • Apply plugin.serialization in every module with @Serializable classes.
  • Match the serialization plugin version to the Kotlin version.
  • Use a convention/version catalog so the plugin is never forgotten.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →