我正在嘗試使用discord4j構建一個不和諧機器人。我將這行代碼添加到 build.gradle 檔案中。
dependencies {
implementation "com.discord4j:discord4j-core:3.2.2"
}
但是,在我嘗試構建應用程式后,構建在 task 失敗: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$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
我注意到模塊中有一個重復的類discord4j-rest和discord4j-voice. 搜索解決方案后,我找到了這個答案:
有時重復類例外意味著您的依賴項之一隱式使用了您也在專案中使用的某些庫的較舊或較新(帶 )版本,
但是,這兩個模塊是 discord4j 的依賴項。因此,我無法force與他們一起使用該功能。我怎么解決這個問題?
uj5u.com熱心網友回復:
我是 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/
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/441965.html
上一篇:AndroidStudio中的Gradle錯誤:找不到“com.android.tools.build:gradle:7.1.1”。
