Gradle 添加 discord4j 库后出错
Gradle error after adding discord4j library
我正在尝试使用 discord4j 构建一个 discord 机器人。我将这行代码添加到 build.gradle 文件中。
dependencies {
implementation "com.discord4j:discord4j-core:3.2.2"
}
但是,在我尝试构建应用程序后,构建在任务 :app:checkDebugDuplicateClasses
处失败。
* 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(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
我注意到模块 discord4j-rest
和 discord4j-voice
中有重复的 class。搜索解决方案后,我发现 this answer:
Sometimes duplicate classes exception means that one of your
dependencies uses implicitly the older or newer (with +) version of
some library you also use in your project,
但是,这2个模块是discord4j的依赖项。因此,我无法对它们使用 force
函数。我该如何解决这个问题?
我是 Discord4J 的开发人员之一,pushed a fix 将受影响的 class 移动到共享模块。
在没有包含它的稳定版本之前,您可以切换到最新的快照来尝试。
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}
dependencies {
implementation 'com.discord4j:discord4j-core:3.2.3-SNAPSHOT'
}
我正在尝试使用 discord4j 构建一个 discord 机器人。我将这行代码添加到 build.gradle 文件中。
dependencies {
implementation "com.discord4j:discord4j-core:3.2.2"
}
但是,在我尝试构建应用程序后,构建在任务 :app:checkDebugDuplicateClasses
处失败。
* 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(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
我注意到模块 discord4j-rest
和 discord4j-voice
中有重复的 class。搜索解决方案后,我发现 this answer:
Sometimes duplicate classes exception means that one of your dependencies uses implicitly the older or newer (with +) version of some library you also use in your project,
但是,这2个模块是discord4j的依赖项。因此,我无法对它们使用 force
函数。我该如何解决这个问题?
我是 Discord4J 的开发人员之一,pushed a fix 将受影响的 class 移动到共享模块。
在没有包含它的稳定版本之前,您可以切换到最新的快照来尝试。
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
}
dependencies {
implementation 'com.discord4j:discord4j-core:3.2.3-SNAPSHOT'
}