kotlinandroid-gradle-pluginkotlin-gradle-plugin

Difference between Kotlin plugins


What are the differences between these three Kotlin plugins and what do they actually do?

plugins {
    id 'kotlin-android'
    id 'org.jetbrains.kotlin.android'
    id "org.jetbrains.kotlin.jvm" version "1.6.20"
}

The third one seems to be the recommended way specially when using Kotlin Coroutines


Solution

  • These plugins provide integration with different other Gradle plugins. They both setup compiling Kotlin for the JVM, but aim to interoperate with different other tools.

    Normally you should only apply one of these plugins, depending on whether you target Android or "standard" JVM. If you need to target both platforms, you should use the Kotlin Multiplatform plugin by ID org.jetbrains.kotlin.multiplatform, which adds the DSL to setup the targets in the project. Those might include jvm() and android(), as well as other targets: JS, WASM, Kotlin/Native.