e:此版本(1.3.2)的Compose Incler需要Kotlin版本1.7.20,但您似乎使用的Kotlin版本1.9.23,目前尚不清楚该版本是否兼容.
这个错误是不言而喻的.对于其他匹配的项目,兼容性做得很好.出于某种原因,无论我在这个项目中做什么,错误都会持续存在.没有对1.3.2的合成编译器的引用.只有主应用程序使用compose.我try 过清洁/无效,结果相同.
这是一个多模块项目.Gradle构建脚本都使用相同的kotlin版本.
Build.gradle(项目)
buildscript {
ext {
kotlin_version = '1.9.23'
compose_version = '1.6.5'
kotlinCompilerExtensionVersion = '1.5.11'
...
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
...
}
}
Build.gradle(应用程序)
apply plugin: 'kotlin-android'
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
composeOptions {
kotlinCompilerExtensionVersion kotlinCompilerExtensionVersion
}
buildFeatures {
compose true
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
// Compose
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
// somewhere on a google doc it noted to NOT include this. Here just in case.
// implementation "androidx.compose.material:material:$compose_version"
}
Build.gradle(模块a)
plugins {
id 'com.android.library'
}
apply plugin: 'kotlin-android'
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.12.0'
}
Build.gradle(模块b)
plugins {
id 'com.android.library'
}
apply plugin: 'kotlin-android'
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.12.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}