当我使用最新版本的ksp和hilt时,它给出了这个错误

问题描述 投票:0回答:1

当我使用最新版本的 ksp 和 hilt 时,出现此错误。

ksp = "2.0.0-1.0.22"
hilt = "2.51.1"

我创建了一个新项目并更新了所有 Google 库并使用最新版本的 gradle。 在使用最新版本的 Hilt 和 Ksp 时,遇到以下错误。

Unable to load class 'org.jetbrains.kotlin.buildtools.api.SourcesChanges'
org.jetbrains.kotlin.buildtools.api.SourcesChanges

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
[versions]
ksp = "2.0.0-1.0.22"
hilt = "2.51.1"

[libraries]
hilt-android-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }

[plugins]
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }`


`//gradle project
  alias(libs.plugins.ksp) apply false
  alias(libs.plugins.hilt) apply false

//gradle module
    alias(libs.plugins.ksp)
    alias(libs.plugins.hilt)

dependencies {
    ksp(libs.hilt.android.compiler)
    implementation(libs.hilt.android)
}

android kotlin dagger-hilt
1个回答
0
投票

确保 Kotlin Android Plugin/Kotlin JVM 和 KSP 的版本匹配。它帮助了我

无法编译:

[versions]
kotlin = "1.9.0"
ksp = "2.0.0-1.0.22"

作品:

[versions]
kotlin = "1.9.0"
ksp = "1.9.0-1.0.12"
© www.soinside.com 2019 - 2024. All rights reserved.