Hey guys, what the meaning of this error `kotlinx.serialization compiler plugin is not applied to t...
v
Hey guys, what the meaning of this error
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.
build.grade(app)
Copy code
plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.vivek.sportsresult"
        minSdk 21
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '<http://proguard-rules.pro|proguard-rules.pro>'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.8.0'
    implementation 'androidx.activity:activity-compose:1.5.0'

    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.material3:material3:$compose_material3_version"
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_preview_version"
    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
    implementation "androidx.navigation:navigation-compose:$nav_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_preview_version"
    debugImplementation "androidx.compose.compiler:compiler:$compose_ui_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"

    testImplementation 'junit:junit:4.13.2'

    androidTestImplementation 'androidx.test.ext:junit:1.1.3'

    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"

    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"

    implementation 'androidx.work:work-runtime:2.7.1'

    implementation "com.google.accompanist:accompanist-systemuicontroller:0.23.0"

    implementation "com.airbnb.android:lottie-compose:$lottieVersion"

    implementation "io.insert-koin:koin-android:$koin_version"
    implementation "io.insert-koin:koin-androidx-compose:$koin_version"

    implementation "com.squareup.moshi:moshi-kotlin:$moshiVersion"
    kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion"

    implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
    implementation "com.squareup.retrofit2:converter-moshi:$retrofit2_version"

    implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
    implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"

    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3"
}
build.gradle(SportsResult)
Copy code
buildscript {
    ext {
        compose_version = '1.1.1'
        compose_ui_version = '1.2.0'
        compose_material3_version = '1.0.0-alpha14'
        compose_preview_version = '1.1.1'
        koin_version = '3.2.0'
        lottieVersion = '5.2.0'
        nav_version = '2.5.0'
        lifecycle_version = '2.5.0'
        moshiVersion = '1.13.0'
        retrofit2_version = '2.9.0'
        okhttp3_version = '4.9.3'
        kotlin_version = '1.7.10'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.2.1' apply false
    id 'com.android.library' version '7.2.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
m
You'll need something like
Copy code
plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'org.jetbrains.kotlin.plugin.serialization'
}
See https://github.com/Kotlin/kotlinx.serialization#gradle
v
I already tried this getting this error
* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.jetbrains.kotlin.plugin.serialization'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
j
try setting the version
Copy code
plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'kotlin-kapt'
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.7.10'
}
or whatever kotlin version are you using, maybe it is
1.6.10
v
Oh nice it fine now
Thank you guys
d
What if I don't use Gradle? I am following https://discuss.kotlinlang.org/t/kotlin-native-and-intellij-idea-without-extra-build-tools-like-gradle-maven/27453 for a 1-day workshop, using intellij, so I believe I'm only relying on .iml files, and I also get the above error ( crossposting from #intellij)
hmm maybe this is not possible , since the plugin is actually called "org.jetbrains.kotlin.plugin.serialization.gradle.plugin"
1768 Views