英文:
How can i solved this error: app:checkDebugDuplicateClasses Failed
问题
Here is the translated content:
我的错误:
> 在模块 kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) 和 kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20) 中找到重复的类 kotlin.collections.jdk8.CollectionsJDK8Kt。
我试图通过更改 build.gradle(Project)中的内容来修复它:
从
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
改为
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
但我遇到了这个错误:
> 'compileDebugJavaWithJavac' 任务(当前目标为 1.8)和
> 'kaptGenerateStubsDebugKotlin' 任务(当前目标为 18)的 JVM 目标兼容性应设置为相同的 Java 版本。
当我尝试在项目中设置 Dagger-Hilt 时,错误开始显示。
我将项目上传到 GitHub,因为我不知道应该共享哪些文件:https://github.com/DawidSiudeja/WordlePL
编辑
我在 build.gradle 的依赖项中添加了以下内容:
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
还有其他错误 :/
英文:
My error:
> Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
I was try to fix it by changing in build.gradle (Project)
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
to
id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
but I got this error:
> 'compileDebugJavaWithJavac' task (current target is 1.8) and
> 'kaptGenerateStubsDebugKotlin' task (current target is 18) jvm target
> compatibility should be set to the same Java version.
The errors starts showing when i try to setup Dagger-Hilt in my project.
I upload project to github, because I don't know which files I should share: https://github.com/DawidSiudeja/WordlePL
EDIT
I add in build.gradle dependencies:
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
and another errors :/
答案1
得分: 1
问题在于您使用了一个与您的Kotlin库版本1.8.0不兼容的Compose编译器库。
您可以按照此处的文档来解决未来的问题:https://developer.android.com/jetpack/androidx/releases/compose-kotlin
步骤来解决问题(根据Kotlin库1.8.0):
您必须将Compose编译器更改为1.4.0或1.4.1。
打开您的build.gradle文件,查找composeOptions,然后将当前版本更改为兼容版本:
composeOptions {
kotlinCompilerExtensionVersion '1.4.0'
}
英文:
The problem is that you use a compose compiler library which is not compatible with your kotlin library in 1.8.0
you can follow the documentation here to solve for future cases: https://developer.android.com/jetpack/androidx/releases/compose-kotlin
Steps to fix: (Acording to kotlin library 1.8.0)
You must need to change la compose compiler to 1.4.0 or 1.4.1
open your build.gradle and look for composeOptions then change the current version for the compatible version:
composeOptions {
kotlinCompilerExtensionVersion '1.4.0'
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论