m

    Marcin Bak

    1 year ago
    In a new IntelliJ kotlin multiplatform project after adding
    kotlin("plugin.serialization")
    and serialization dependency in common module I don't get generated serializers and get a warning on
    @Serializable
    kotlinx.serialization compiler plugin is not applied to the module, so this annotation would not be processed. Make sure that you've setup your buildscript correctly and re-import project.
    The main build.gradle.kts contains proper buildscript dependencies
    classpath(kotlin("gradle-plugin", version = "1.4.31"))
    classpath(kotlin("plugin.serialization", version = "1.4.31"))
    Nothing seems to help. I've removed all unnecessary code, reimported project, invalidated caches but to no avail. Any ideas?
    a

    Alexis Manin

    1 year ago
    I don't know gradle very well, but the lines you show does not look like plugin declaration, as shown in kotlin serialization doc: https://github.com/Kotlin/kotlinx.serialization#gradle
    m

    Marcin Bak

    1 year ago
    @Alexis Manin if Gradle part was a problem then it would probably throw a build error. What's even weirder - the serialization works and I guess it's an issue with IntelliJ
    andylamax

    andylamax

    1 year ago
    I am with @Alexis Manin on this one, if its okay with you, please post your whole build.gradle.kt
    Oliver.O

    Oliver.O

    1 year ago
    The top lines of your build.gradle.kts should look like this:
    plugins {
        kotlin("multiplatform") version "1.4.32"
        kotlin("plugin.serialization") version "1.4.32"
        application
    }
    If not, there is no plugin generating serializers as indicated in the error message you were getting.
    m

    Marcin Bak

    1 year ago
    Yes, I have that part in my modules build.gradle.kts What's strange is that IntelliJ is showing the warning, but the app runs without troubles and data gets serialized/deserialized properly
    a

    adk

    1 year ago
    IntelliJ is often a bit fussy with gradle builds. What version of gradle are you using? Do you have the gradle wrapper set up? Is IntelliJ configured to use the gradle from your
    gradle/gradle-wrapper.properties
    file? Do you have nested modules/projects using either
    include(...)
    or
    includeBuild(...)
    ? Are you using
    buildSrc
    for managing build logic? I have found that IntelliJ is easily confused by these constructs.
    m

    Marcin Bak

    1 year ago
    @adk yes, I have gradle wrapper, version gradle-6.8.2 and Intellij is using the wrapper. Not using buildSrc, nor includeBuild and include in settings.gradle.kts only the modules generated by wizard
    m

    Mouaad

    1 year ago
    I am having the same issue for weeks now! did you find any solution for it @Marc Knaup?
    m

    Marc Knaup

    1 year ago
    @Mouaad me? 🤔
    m

    Marcin Bak

    1 year ago
    @Mouaad no I haven't. I simply got used to the warning and kept on going 😄
    a

    adk

    1 year ago
    Hmmm, looks like this is probably a bug. I just created a new minimal project from scratch and set up serialization and I also get a warning in IntelliJ - although serialization works fine. Oddly, if I move the
    @Serializable
    class from
    commonMain
    to
    commonTest
    , the warning goes away.
    m

    Marcin Bak

    1 year ago
    Yeah. I moved my class from common to jvm module and also this made the warning go away
    m

    Mouaad

    1 year ago
    Sorry I tagged the wrong person 😄 Yes, I am having the same issue on different computers! so annoying 😕
    Update: using kotlin 1.5.0 fixed the issue for me!!