79600850

Date: 2025-04-30 17:43:48
Score: 5
Natty:
Report link

I have the same issue, This is how I setup kotlinx.serialization based on the guide from their github page https://github.com/Kotlin/kotlinx.serialization and the same with here.
From step 1, it is not clear where to put this code

plugins {
    kotlin("jvm") version "2.1.20" // or kotlin("multiplatform") or any other kotlin plugin
    kotlin("plugin.serialization") version "2.1.20"
}

Then I put it into build.gradle.kts at project-level, since adding into module-level gives me error.

On step 2, I am adding dependency into my build.gradle.kts at module-level:

dependencies {
    ...
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
}

But after I add annotation on my data class it gives me warning.

How I solve

I am adding the plugin.serialization into build.gradle.kts at module-level:

plugins {
    ...
    kotlin("plugin.serialization") // add this
}

Then sync your gradle

Reasons:
  • Blacklisted phrase (1): I have the same issue
  • Blacklisted phrase (2): gives me error
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): I have the same issue
  • Low reputation (0.5):
Posted by: Fuad Reza