今天我在Android Studio Hedgehog中创建了一个空的Kotlin多平台应用**| 2023.1.1**我只在shared
文件夹的build.gradle
的插件部分添加了一行:
id("com.squareup.sqldelight") version "1.5.5"
字符串
按下同步按钮后,我得到了一个错误
shared/build.gradle.kts:9:5: Unresolved reference: androidTarget
型
我敢肯定,这不是错误的初始文件结构,这是关于sqldelight插件行本身-坏语法或这样。作为参考,我在这里留下一些文件:build.gradle.kts
共享文件夹(仅第一行):
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
id("com.squareup.sqldelight") version "1.5.5"//this line was added only
}
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
....
型
项目build.gradle.kts
(全线):
plugins {
//trick: for the same plugin versions in all sub-modules
alias(libs.plugins.androidApplication).apply(false)
alias(libs.plugins.androidLibrary).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.kotlinMultiplatform).apply(false)
}
型libs.versions.toml
(所有线路)
[versions]
agp = "8.2.0"
kotlin = "1.9.20"
compose = "1.5.4"
compose-compiler = "1.5.4"
compose-material3 = "1.1.2"
androidx-activityCompose = "1.8.0"
[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "compose-material3" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
型
我还尝试了另一种语法与该插件,在build.gradle
的共享我添加
alias(libs.plugins.sqldelightPlugin)
型
在libs.versions.toml
中,
[versions]
....
sqldelight = "1.5.5"
[plugins]
....
sqldelightPlugin = { id = "com.squareup.sqldelight", version.ref = "sqldelight" }
型
但无论如何,我还是犯了同样的错误。
如何正确将com.squareup.sqldelight
插件添加到Kotlin多平台项目的共享build.gradle
中?
1条答案
按热度按时间kmb7vmvb1#
最新版本
对于最新版本,用途:
字符串
参见documentation。
旧版本
在1.5.5版本结束时,他们在不同的插件ID下发布了它,而不是在Gradle插件门户上。如果你必须使用1.5.5,你需要用途:
型
参见old documentation。