首页 > 其他分享 >包解决!Android Studio报错:Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules

包解决!Android Studio报错:Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules

时间:2024-10-13 13:49:32浏览次数:7  
标签:CollectionsJDK8Kt 21 kotlin 1.8 报错 stdlib org jetbrains

Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.io.path.ExperimentalPathApi found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.io.path.PathRelativizer found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.io.path.PathsKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.io.path.PathsKt__PathReadWriteKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.io.path.PathsKt__PathUtilsKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.jdk7.AutoCloseableKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
     Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and jetified-kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)

* 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 6s
219 actionable tasks: 215 executed, 4 up-to-date

报错代码如上,具体情况是我写了一个 简易秒表的app 用到了 Chronometer 我一直以为是因为这个xml中的标签或者是java类中因为创建这个对象引入了某些东西导致报错(现在解决了发现不是的),因为我在写这个app之前,所有的app都能正常运行。

直到我写了这个app点击运行 发现有了上面的报错 然后去试了其他的app和API 无一例外全部报同样的错。

然后就开始了漫长的复制错误 - 搜索 - 尝试帖子方法 - 依旧报错 - 搜索 - 尝试 - ……

试了很多方法都不行 直到看到了这么一个帖子:
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules。Android studio纯java代码报错

发现他和我的报错一模一样 然后试了他的方法 是在dependencies里面加了一句 然后点击sync 等下载一堆文件后 就能运行了

虽然目前还是不知道原理是什么

有人的解释是:

作者的解释是:

 只能说无论如何终于是解决了问题,感谢赛博华佗 Night_Journey 大佬!!!

献上解决方案

在Gradle Scripts里的build.gradle.kts添加上这段代码就好了

(如果是groovy的话 就是对应的build.gradle(:模块名) 一个大象图标)

dependencies {
   ... ... ...
   implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
   ... ... ...

}

标签:CollectionsJDK8Kt,21,kotlin,1.8,报错,stdlib,org,jetbrains
From: https://blog.csdn.net/yc040416/article/details/142896543

相关文章

  • v4501v.dll文件缺失或损坏?从根源入手轻松解决v4501v.dll文件报错
    当您在使用计算机时遇到“找不到v4501v.dll”或“v4501v.dll缺失/损坏”的错误提示,这意味着您的系统中缺少或损坏了一个重要的动态链接库文件。v4501v.dll文件通常是某些应用程序或游戏正常运行所必需的组件之一,缺失或损坏该文件会导致相关程序无法启动或运行异常。为了确保您......
  • ORB_SLAM2 编译失败报错
    编译前,对部分包的要求:Pangolin==0.5Eigen>=3.1.0(可安装3.1.0)OpenCV3==3.x.x(可安装3.4.15)通常,Eigen直接在终端使用apt-get安装libeigen3-dev即可Pangolin最好是不要直接安装最新的版本,否则在编译过程中会出现/usr/lib/ldcannotfindlEigen3::Eigen的错误......
  • C# LINQ 查询报错:指定的转换无效
     usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Dynamic;usingSystem.Linq;usingSystem.Runtime.CompilerServices;usingSystem.Data.Linq;usingSystem.Data.Linq.Mapping;usingSystem.......
  • 泛微e-cology安装报错 MySQL初始化问题Table 'ecology.e9_para_xxx' doestn't exist
    在安装泛微e-cology9进行初始化数据库时出现如下报错Table 'ecology.e9_para_xxx'doestn'texist 明明是在初始化数据库  数据表不存在不是很正常==经过研究  发现泛微在初始化数据库时 会执行存储过程脚本  使用dbeaver可以看到 根据代码逻辑看  如......
  • Idea android应用kotlin-stdlib-1.8.20 kotlin-stdlib-jdk81.6.21冲突
    Ideaandroid应用kotlin-stdlib-1.8.20kotlin-stdlib-jdk81.6.21冲突idea中开发android应用,安装android插件后,新建项目,然后各种包更新,最后运行时提示kotlin-stdlib-1.8.20kotlin-stdlib-jdk8:1.6.21冲突错误如下:FAILURE:Buildfailedwithanexception.Whatwentwrong:......
  • oracle 19c dgbroker 报错ORA-16664 with ORA-12514如何解决
    alert中一堆这个保存一新***********************************************************************FatalNIconnecterror12504,connectingto:(DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=)(INSTANCE_NAME=hrz)(CID=(PROGRAM=oracle)(HOST=sd4)(USER=oracle)))(ADDRESS......
  • 最新Qt6将可执行文件打包为独立exe保姆级教学!含报错:无法定位程序输入点于动态链接库解
     相信大家都有类似的体验,自己已经在Qt练习中写出了不错的小程序,每次想发给别人体验都要发一整个大代码包,还得对面有对应的装好的QT才能运行,或者是想把自己的成果记录下来作为一个单独的exe文件却没有办法,今天教大家Qt如何生成独立可执行exe。注意:以下是Qt6之前版本可用的全过......
  • 使用echarts报错【echarts使用示例】
    错误代码<template><h1>home</h1><divid="main"style="width:600px;height:400px;"></div></template><scriptsetup>import{onMounted}from'vue';import*asechartsfrom'ec......
  • 【信创问题】解决东方通(TongWeb)报错 java.lang.NoClassDefFoundError: javax/persis
    写在前边今天帮现场同事定位问题,情况是项目同事使用东方通(TongWeb7.0)部署公司项目时,出现以下报错导致服务启动失败。简单排查了下发现:war包内WEB-INF/lib/javax.persistence-api-2.2.jar中包含javax.persistence.spi.PersistenceProvider这个接口,不应该报这个错误呀。Causedby......
  • vue ui创建项目报错:Cannot read property 'indexOf' of undefined解决方法
    本来以为是个很简单的小报错,在网上搜了几个教程竟然都没有解决,整了快半个小时,越整越烦躁。最后忍无可忍重新安装了一遍nodejs,竟然还报这个错...突然想到自己一直没去看详细的报错日志,于是在黑窗看了一下报错内容:原来是权限不够(注:之前用系统管理员身份运行过,创建项目那里目录一......