【问题标题】:Android Studio: How to access project level compileSdkVersion and targetSdkVersion in Kotlin Multiplatform shared module build.gradle.kts?Android Studio:如何在 Kotlin Multiplatform 共享模块 build.gradle.kts 中访问项目级 compileSdkVersion 和 targetSdkVersion?
【发布时间】:2021-01-08 06:41:21
【问题描述】:

我正在尝试将 KMM 共享模块添加到我现有的 Android Studio 项目中。我想在共享模块中使用项目级 build.gradle 中的 compileSdkVersion 和 targetSdkVersion,但我似乎无法使用它。

这是来自共享模块 build.gradle.kts 的代码 sn-p:

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")
}

我该怎么做?

【问题讨论】:

    标签: android android-studio build.gradle gradle-kotlin-dsl kotlin-multiplatform


    【解决方案1】:

    您可以在buildSrc 中创建一个Dependencies/Versions 文件来指定可供多个模块重用的版本。

    例子见https://github.com/joreilly/PeopleInSpace/blob/master/buildSrc/src/main/java/Dependencies.kt

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-13
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 2020-03-01
      • 1970-01-01
      • 2022-11-23
      相关资源
      最近更新 更多