我正在尝试将 KMM 共享模块添加到我现有的 Android Studio 项目中。我想在共享模块中使用项目级别 build.gradle 中的compileSdkVersion和targetSdkVersion,但我似乎无法使用它。
这是共享模块build.gradle.kts的代码 fragment :
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")
}
我该怎么做?
最佳答案
您可以在 buildSrc
中创建一个 Dependency/Versions
文件来指定可由多个模块重用的版本。
有关示例,请参阅 https://github.com/joreilly/PeopleInSpace/blob/master/buildSrc/src/main/java/Dependencies.kt
关于Android Studio : How to access project level compileSdkVersion and targetSdkVersion in Kotlin Multiplatform shared module build. gradle.kts?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65624486/