Applying the 'kotlinx-serialization' plugin in the application gradle file will result in an error stating that this plugin is unfound.
Are there some additional plugins I need to add in my gradle file in order for the serialization plugin to be found ?
Have you added maven { url "https://kotlin.bintray.com/kotlinx" } in buildscript repositories?
yes I did
Rather strange. Take a look at example project configuration, it should 100% work: https://github.com/Kotlin/kotlinx.serialization/blob/master/example-jvm/build.gradle.
Probably you use new gradle plugin block instead of apply plugin ..., which doesn't work for now, because plugin is not uploaded to Gradle Plugin Portal
maybe the latest kotlin plugin named 'kotlin-android' includes the serialization one, thank you anyway
No, I don't think so. Serialization plugin was not bundled anywhere
@wessimtrimeche are you using Kotlin DSL? I had the same problem.
I fixed it by adding the following to the settings.gradle.kts:
pluginManagement({
repositories {
gradlePluginPortal()
maven("https://kotlin.bintray.com/kotlinx")
}
resolutionStrategy {
eachPlugin {
when (requested.id.id) {
"kotlinx-serialization"->{
useModule("org.jetbrains.kotlinx:kotlinx-gradle-serialization-plugin:${requested.version}")
}
}
}
}
})
and the following in the build.gradle.kts
plugins {
id("kotlinx-serialization") version "0.4.1" apply true
}
I am not familiar with "groovy" gradle, but since they are similar maybe this can help you.
Edit: Also, I am using Gradle 4.5.1 , this is very important, the older versions (4.3 and below I think) does not have the Kotlin DSL plugin in them, but you can add it manually I think
As a note, the same code (except for when - use an if) works for groovy based build scripts.
in your build.graddle (Project)
in dependencies, add this line
dependencies {
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
Most helpful comment
in your build.graddle (Project)
in dependencies, add this line
dependencies {
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}