我如何解决这个错误:app:checkDebugDuplicateClasses 失败

huangapple go评论155阅读模式
英文:

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'
}

我如何解决这个错误:app:checkDebugDuplicateClasses 失败

英文:

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

我如何解决这个错误:app:checkDebugDuplicateClasses 失败

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'
}

huangapple
  • 本文由 发表于 2023年6月6日 03:32:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76409495.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定