gpt4 book ai didi

安卓 Gradle 3.0 : Multiple dex files define Lorg/jetbrains/annotations/TestOnly

转载 作者:太空狗 更新时间:2023-10-29 13:05:31 28 4
gpt4 key购买 nike

看起来像一个磨坊 unable to merge dex 问题,但是,我找不到重复的依赖项来自哪里。 app:dependencies 打印输出粘贴在下面。

如您所见,org.jetbrains:annotations:13.0 在这里只存在一次。我读错了吗?我可以使用哪些其他命令来查找重复的依赖项?

- com.google.firebase:firebase-core:11.8.0
| \--- com.google.firebase:firebase-analytics:11.8.0
| +--- com.google.android.gms:play-services-basement:11.8.0
| | +--- com.android.support:support-v4:25.2.0 -> 27.0.2
| | | +--- com.android.support:support-compat:27.0.2
| | | | +--- com.android.support:support-annotations:27.0.2
| | | | \--- android.arch.lifecycle:runtime:1.0.3
| | | | +--- android.arch.lifecycle:common:1.0.3
| | | | \--- android.arch.core:common:1.0.0
| | | +--- com.android.support:support-media-compat:27.0.2
| | | | +--- com.android.support:support-annotations:27.0.2
| | | | \--- com.android.support:support-compat:27.0.2 (*)
| | | +--- com.android.support:support-core-utils:27.0.2
| | | | +--- com.android.support:support-annotations:27.0.2
| | | | \--- com.android.support:support-compat:27.0.2 (*)
| | | +--- com.android.support:support-core-ui:27.0.2
| | | | +--- com.android.support:support-annotations:27.0.2
| | | | \--- com.android.support:support-compat:27.0.2 (*)
| | | \--- com.android.support:support-fragment:27.0.2
| | | +--- com.android.support:support-compat:27.0.2 (*)
| | | +--- com.android.support:support-core-ui:27.0.2 (*)
| | | +--- com.android.support:support-core-utils:27.0.2 (*)
| | | \--- com.android.support:support-annotations:27.0.2
| | \--- com.google.android.gms:play-services-basement-license:11.8.0
| +--- com.google.firebase:firebase-common:11.8.0
| | +--- com.google.android.gms:play-services-basement:11.8.0 (*)
| | +--- com.google.android.gms:play-services-tasks:11.8.0
| | | +--- com.google.android.gms:play-services-basement:11.8.0 (*)
| | | \--- com.google.android.gms:play-services-tasks-license:11.8.0
| | \--- com.google.firebase:firebase-common-license:11.8.0
| +--- com.google.firebase:firebase-analytics-impl:11.8.0
| | +--- com.google.android.gms:play-services-basement:11.8.0 (*)
| | +--- com.google.firebase:firebase-iid:11.8.0
| | | +--- com.google.android.gms:play-services-basement:11.8.0 (*)
| | | +--- com.google.firebase:firebase-common:11.8.0 (*)
| | | +--- com.google.android.gms:play-services-tasks:11.8.0 (*)
| | | \--- com.google.firebase:firebase-iid-license:11.8.0
| | +--- com.google.firebase:firebase-common:11.8.0 (*)
| | +--- com.google.android.gms:play-services-tasks:11.8.0 (*)
| | \--- com.google.firebase:firebase-analytics-impl-license:11.8.0
| \--- com.google.firebase:firebase-analytics-license:11.8.0
+--- com.android.support:appcompat-v7:27.0.2
| +--- com.android.support:support-annotations:27.0.2
| +--- com.android.support:support-core-utils:27.0.2 (*)
| +--- com.android.support:support-fragment:27.0.2 (*)
| +--- com.android.support:support-vector-drawable:27.0.2
| | +--- com.android.support:support-annotations:27.0.2
| | \--- com.android.support:support-compat:27.0.2 (*)
| \--- com.android.support:animated-vector-drawable:27.0.2
| +--- com.android.support:support-vector-drawable:27.0.2 (*)
| \--- com.android.support:support-core-ui:27.0.2 (*)
+--- com.android.support:support-v4:27.0.2 (*)
+--- com.android.support:design:27.0.2
| +--- com.android.support:support-v4:27.0.2 (*)
| +--- com.android.support:appcompat-v7:27.0.2 (*)
| +--- com.android.support:recyclerview-v7:27.0.2
| | +--- com.android.support:support-annotations:27.0.2
| | +--- com.android.support:support-compat:27.0.2 (*)
| | \--- com.android.support:support-core-ui:27.0.2 (*)
| \--- com.android.support:transition:27.0.2
| +--- com.android.support:support-annotations:27.0.2
| \--- com.android.support:support-compat:27.0.2 (*)
+--- org.jetbrains.kotlin:kotlin-stdlib:1.2.21
| \--- org.jetbrains:annotations:13.0
+--- com.github.salomonbrys.kodein:kodein:4.1.0
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2 -> 1.2.21 (*)
| \--- com.github.salomonbrys.kodein:kodein-core:4.1.0
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2 -> 1.2.21 (*)
+--- nl.komponents.kovenant:kovenant-core:3.3.0
+--- nl.komponents.kovenant:kovenant-android:3.3.0
| +--- nl.komponents.kovenant:kovenant-core:3.3.0
| \--- nl.komponents.kovenant:kovenant-ui:3.3.0
| \--- nl.komponents.kovenant:kovenant-core:3.3.0
+--- com.github.ozodrukh:CircularReveal:2.0.1
+--- com.google.firebase:firebase-crash:11.8.0
| +--- com.google.android.gms:play-services-basement:11.8.0 (*)
| +--- com.google.firebase:firebase-iid:11.8.0 (*)
| +--- com.google.firebase:firebase-common:11.8.0 (*)
| +--- com.google.firebase:firebase-analytics:11.8.0 (*)
| \--- com.google.firebase:firebase-crash-license:11.8.0
+--- com.squareup.retrofit2:retrofit:2.3.0
| \--- com.squareup.okhttp3:okhttp:3.8.0
| \--- com.squareup.okio:okio:1.13.0
+--- com.squareup.retrofit2:converter-gson:2.3.0
| +--- com.squareup.retrofit2:retrofit:2.3.0 (*)
| \--- com.google.code.gson:gson:2.7 -> 2.8.0
+--- com.github.salomonbrys.kotson:kotson:2.5.0
| +--- com.google.code.gson:gson:2.8.0
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.0.6 -> 1.2.21 (*)
+--- org.funktionale:funktionale-all:1.1
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.2-2 -> 1.2.21 (*)
+--- io.reactivex.rxjava2:rxkotlin:2.1.0
| +--- io.reactivex.rxjava2:rxjava:2.1.0
| | \--- org.reactivestreams:reactive-streams:1.0.0
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.3 -> 1.2.21 (*)
+--- com.github.kittinunf.fuel:fuel-android:1.10.0
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4-3 -> 1.2.21 (*)
| \--- com.github.kittinunf.fuel:fuel:1.10.0
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4-3 -> 1.2.21 (*)
| \--- com.github.kittinunf.result:result:1.2.0
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.1.4-3 -> 1.2.21 (*)
+--- com.beust:klaxon:0.30
+--- com.android.support:cardview-v7:27.0.2
| \--- com.android.support:support-annotations:27.0.2
+--- com.android.support:recyclerview-v7:27.0.2 (*)
+--- com.nshmura:snappysmoothscroller:1.0.0
| \--- com.android.support:recyclerview-v7:24.0.0 -> 27.0.2 (*)

build.gradle 中定义的依赖:

implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support:design:27.0.2'

implementation ("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") {
exclude group: 'org.jetbrains', module: 'annotations'
}
implementation 'com.github.salomonbrys.kodein:kodein:4.1.0'
implementation 'nl.komponents.kovenant:kovenant-core:3.3.0'
implementation 'nl.komponents.kovenant:kovenant-android:3.3.0'

implementation ('com.github.ozodrukh:CircularReveal:2.0.1@aar')

implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'

implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation'com.github.salomonbrys.kotson:kotson:2.5.0'
implementation "org.funktionale:funktionale-all:$functionale_version"
implementation "io.reactivex.rxjava2:rxkotlin:$rxkotlin_version"

implementation 'com.github.kittinunf.fuel:fuel-android:1.10.0'
implementation 'com.beust:klaxon:0.30'

implementation ('com.android.support:cardview-v7:27.0.2')
implementation ('com.android.support:recyclerview-v7:27.0.2', {
exclude module: 'support-compat'
exclude module: 'support-core-ui'
exclude module: 'support-annotations'
})
implementation 'com.nshmura:snappysmoothscroller:1.0.0'

编辑:构建命令输出

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
at com.android.builder.dexing.DxDexArchiveMerger.mergeMultidex(DxDexArchiveMerger.java:266)
at com.android.builder.dexing.DxDexArchiveMerger.mergeDexArchives(DxDexArchiveMerger.java:133)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:97)
at com.android.build.gradle.internal.transforms.ExternalLibsMergerTransform.transform(ExternalLibsMergerTransform.kt:121)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
Caused by: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:72)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
... 46 more
Caused by: com.android.dex.DexException: Multiple dex files define Lorg/jetbrains/annotations/TestOnly;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
... 47 more

我尝试了所有我能找到的基本东西,例如:

  • 清理构建
  • 删除 .gradle 目录

最佳答案

原来是 Funktionale 有点坏公民导致了这个问题。使用给定类的类查找(Windows 上的 Ctrl + N),我得到了两个结果。其中一个位于预期的 JetBrains 注释包中,另一个位于 Funktionale 的注释包中。

The search results

查看这个包的内容,里面其实包含了一大堆外部定义的注解:

The contents of the Funktionale distribution

我不能说他们为什么这样做而不是将这些库声明为依赖项。


现在,列出可能的解决方案。

  1. 打开依赖项提供的 .jar 文件,从中删除有问题的包,重新打包,并将其作为本地 .jar 文件包含在您的项目中。

  2. 研究尝试从 Gradle 依赖项中删除 .class 文件的骇人听闻的解决方案。我找到了 this在调查这个问题时,但它似乎对我不起作用。

  3. 在 GitHub 上向库作者提出问题并等待响应和新版本。

  4. 删除并重新发布有问题的包的库。

  5. 使用 Arrow反而。这是一个新的功能性 Kotlin 库,由 Funktionale 和 Kategory 的维护者共同创建。他们在 Talking Kotlin 播客节目中谈论它 here .不幸的是,我没有使用这两个库的个人经验,但它可能适合您的需要。

关于安卓 Gradle 3.0 : Multiple dex files define Lorg/jetbrains/annotations/TestOnly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48504912/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com