Saurabh Somani
Saurabh Somani

Reputation: 95

Android Studio: How to access project level compileSdkVersion and targetSdkVersion in Kotlin Multiplatform shared module build.gradle.kts?

I am trying to add a KMM shared module to my existing Android Studio project. I would like to use the compileSdkVersion and targetSdkVersion from project level build.gradle in the shared module, but I can't seem to use it.

Here's the code snippet from shared module build.gradle.kts:

android {
    compileSdkVersion(30) // I want to use a project-wide variable here instead of '30'
    defaultConfig {
        minSdkVersion(23) // And here
        targetSdkVersion(30) // And here
    }
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
}

How can I do this?

Upvotes: 3

Views: 913

Answers (1)

Róbert Nagy
Róbert Nagy

Reputation: 7690

You can create a Dependencies/Versions file in your buildSrc to specify versions, that can be reused by multiple modules.

For an example see https://github.com/joreilly/PeopleInSpace/blob/master/buildSrc/src/main/java/Dependencies.kt

Upvotes: 2

Related Questions