我最近在Android Studio Flamingo中创建了一个Compose应用程序,并添加了房间依赖项。
在编译时,我得到了这个错误:
gradle后台进程--无后台进程
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/8.3/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build
> Task :app:kaptGenerateStubsDebugKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsDebugKotlin'.
> Error while evaluating property 'compilerOptions.jvmTarget' of task ':app:kaptGenerateStubsDebugKotlin'.
> Failed to calculate the value of property 'jvmTarget'.
> Unknown Kotlin JVM target: 20
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 36s
13 actionable tasks: 1 executed, 12 up-to-date
然后在阅读了许多帖子后,我跑了:
gradle后台进程--no-daemon --stacktrace
--- very long output ---
Caused by: java.lang.IllegalArgumentException: Unknown Kotlin JVM target: 20
at org.jetbrains.kotlin.gradle.dsl.JvmTarget$Companion.fromTarget(JvmTarget.kt:26)
at org.jetbrains.kotlin.gradle.tasks.DefaultKotlinJavaToolchain$wireJvmTargetToToolchain$1$1.invoke(DefaultKotlinJavaToolchain.kt:78)
at org.jetbrains.kotlin.gradle.tasks.DefaultKotlinJavaToolchain$wireJvmTargetToToolchain$1$1.invoke(DefaultKotlinJavaToolchain.kt:70)
at org.jetbrains.kotlin.gradle.tasks.DefaultKotlinJavaToolchain$sam$org_gradle_api_Transformer$0.transform(DefaultKotlinJavaToolchain.kt)
at org.gradle.api.internal.provider.ValueSupplier$Present.transform(ValueSupplier.java:541)
at org.gradle.api.internal.provider.TransformBackedProvider.mapValue(TransformBackedProvider.java:91)
at org.gradle.api.internal.provider.TransformBackedProvider.calculateOwnValue(TransformBackedProvider.java:83)
at org.gradle.api.internal.provider.AbstractMinimalProvider.calculateValue(AbstractMinimalProvider.java:108)
at org.gradle.api.internal.provider.TransformBackedProvider.calculateOwnValue(TransformBackedProvider.java:82)
at org.gradle.api.internal.provider.AbstractMinimalProvider.calculateValue(AbstractMinimalProvider.java:108)
at org.gradle.api.internal.provider.AbstractMinimalProvider.withFinalValue(AbstractMinimalProvider.java:164)
at org.gradle.api.internal.provider.DefaultProperty.finalValue(DefaultProperty.java:133)
at org.gradle.api.internal.provider.DefaultProperty.finalValue(DefaultProperty.java:26)
at org.gradle.api.internal.provider.AbstractProperty.finalizeNow(AbstractProperty.java:245)
... 110 more
现在我也不知道该怎么解决这个问题
我做的事情:
- 交叉检查
@Query
SQL语句(没有问题) - 如果所有注解都正确完成,
- 更改AS设置以使用jvm 20和1.9.0Kotlin
这是我的app/build.gradle.kts
文件:
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
}
android {
namespace = "<hidden>"
compileSdk = 33
defaultConfig {
applicationId = "<hidden>"
minSdk = 26
targetSdk = 33
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8 // Tried VERSION_20 but no chnages
targetCompatibility = JavaVersion.VERSION_1_8 // " " " "
}
kotlinOptions {
jvmTarget = "1.8" // Tried 20 but Showed unknown jvmTarget here
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.3"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
val navigation_version = "2.6.0"
val room_version = "2.5.2"
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
implementation("androidx.activity:activity-compose:1.7.2")
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation("androidx.navigation:navigation-compose:$navigation_version")
implementation("androidx.compose.material:material-icons-extended:1.4.0")
implementation("androidx.room:room-ktx:$room_version")
kapt("androidx.room:room-compiler:$room_version")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
}
我的根/build.gradle.kts
文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.1.1" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
}
如何解决这一问题???
1条答案
按热度按时间mzillmmw1#
为什么要尝试第20版?
试试这个配置: