https://kotlinlang.org logo
m

Marko Novakovic

09/24/2021, 10:53 PM
how and where to apply
Copy code
plugins {
    id("org.jetbrains.kotlin.android") version "1.5.21"
}
? if I add it anywhere everything falls apart and I can’t run app any more. modules disappear am trying to adopt Compose, is this required or not?
k

kevindmoore

09/25/2021, 5:19 PM
I usually have something like this in the app build.gradle file:
Copy code
plugins {
  id("com.android.application")
  kotlin("android")
}
I specify the version in the top level gradle file in the classpath
e

ephemient

09/28/2021, 1:08 AM
I prefer to use
settings.gradle.kts
to manage plugin versions,
Copy code
pluginManagement {
    plugins {
        resolutionStrategy {
            eachPlugin {
                val id = requested.id.id
                when {
                    id.startsWith("com.android.") ->
                        useModule("com.android.tools.build:gradle:7.0.2")
                    id.startsWith("org.jetbrains.kotlin.") -> useVersion("1.5.31")
                }
            }
        }
    }
}
then you can
plugins { id("com.android.application"); kotlin("android") }
in any
build.gradle
script without having to think about versions
👍 1
m

Marko Novakovic

09/28/2021, 9:28 AM
I used to do it like that, inside
settings.gradle.kts
but when I did it messed up whole build. I made it work tho
3 Views