当前位置: 首页 > 知识库问答 >
问题:

添加discord4j库后出现分级错误

徐正雅
2023-03-14

我正在尝试用discord4j构建一个discordbot。我将这行代码添加到build.gradle文件中。

dependencies {
    implementation "com.discord4j:discord4j-core:3.2.2"
}

然而,在我尝试构建应用程序后,构建在task < code >:app:checkdebugduplicateclass 处失败。

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.iwebpp.crypto.TweetNaclFast found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
     Duplicate class com.iwebpp.crypto.TweetNaclFast$Box found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
     Duplicate class com.iwebpp.crypto.TweetNaclFast$Box$KeyPair found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
     Duplicate class com.iwebpp.crypto.TweetNaclFast$Hash found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
     Duplicate class com.iwebpp.crypto.TweetNaclFast$ScalarMult found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
     Duplicate class com.iwebpp.crypto.TweetNaclFast$SecretBox found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
     Duplicate class com.iwebpp.crypto.TweetNaclFast$Signature found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
     Duplicate class com.iwebpp.crypto.TweetNaclFast$Signature$KeyPair found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
     Duplicate class com.iwebpp.crypto.TweetNaclFast$poly1305 found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
     
     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:checkDebugDuplicateClasses'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:188)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:186)
    at ...
    
Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
    at org.gradle.workers.internal.DefaultWorkerExecutor$WorkItemExecution.waitForCompletion(DefaultWorkerExecutor.java:342)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:142)
    at org.gradle.internal.work.DefaultAsyncWorkTracker.waitForItemsAndGatherFailures(DefaultAsyncWorkTracker.java:94)
    at ...
    
Caused by: java.lang.RuntimeException: Duplicate class com.iwebpp.crypto.TweetNaclFast found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
Duplicate class com.iwebpp.crypto.TweetNaclFast$Box found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
Duplicate class com.iwebpp.crypto.TweetNaclFast$Box$KeyPair found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
Duplicate class com.iwebpp.crypto.TweetNaclFast$Hash found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
Duplicate class com.iwebpp.crypto.TweetNaclFast$ScalarMult found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
Duplicate class com.iwebpp.crypto.TweetNaclFast$SecretBox found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
Duplicate class com.iwebpp.crypto.TweetNaclFast$Signature found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
Duplicate class com.iwebpp.crypto.TweetNaclFast$Signature$KeyPair found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)
Duplicate class com.iwebpp.crypto.TweetNaclFast$poly1305 found in modules discord4j-rest-3.2 (com.discord4j:discord4j-rest:3.2.2) and discord4j-voice-3.2 (com.discord4j:discord4j-voice:3.2.2)

Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.
    at com.android.build.gradle.internal.tasks.CheckDuplicateClassesDelegate.run(CheckDuplicateClassesDelegate.kt:71)
    at com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable.execute(CheckDuplicateClassesDelegate.kt:98)
    at ...


* Get more help at https://help.gradle.org

BUILD FAILED in 6s

我注意到模块不和谐4jRest和不和谐4j语音中有一个重复的类。搜索解决方案后,我找到了这个答案:

有时,重复类异常意味着某个依赖项隐式使用了项目中使用的某个库的较旧或较新版本,

但是,这两个模块是discord4j的依赖项。因此,我无法对它们使用< code>force功能。我该如何解决这个问题?

共有1个答案

田宇
2023-03-14

我是Discord4J的开发人员之一,已经推出了将受影响的类移动到共享模块的修复程序。

在包含它的稳定版本之前,您可以切换到最新的快照进行尝试。

repositories {
  maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
  mavenCentral()
}

dependencies {
  implementation 'com.discord4j:discord4j-core:3.2.3-SNAPSHOT'
}

来自: https://docs.discord4j.com/using-snapshots/

 类似资料:
  • 我错过了什么依赖吗?

  • 所以,自从我在AndroidManifest文件中添加了一个服务块后,我一直收到一个错误,请查看我的清单。 错误显示: “失败[INSTALL_PARSE_FAILED_MANIFEST_MALFORMED:在安装PackageLI:/data/app/vmdl1643630122.tmp/base.apk(位于二进制XML文件行#42):com.example.shoutout.MainActi

  • 我尝试创建自己的taglib,它扩展了现有的taglib:liferay-UI中的input-asset-links。因此,我在my-ext-web中的web-inf/tld中创建了文件liferay-ui-ext.tld,其中xml如下: 我还在web.xml中添加了以下代码: 13:48:19,661错误[http-bio-8080-exec-22][includetaG:129]当前URL/

  • 我想在我的Flutter应用程序中实施Firebase云消息传递,我开始实施Android部分。我像在Firebase留档中一样添加了依赖项,但现在我在构建应用程序时遇到了gradle错误: 我对gradle一点经验都没有,所以我希望能得到一些帮助^^ 以下是应用/构建。格拉德尔 这是项目建设。gradle(如果需要):

  • 添加此插件后,image_editor_pro在获取包时显示此错误… [memeistan]flutter pub get在memeistan中运行“flutter pub get”... 当前Dart SDK版本为2.10.4。