Android Gradle 3.0: несколько файлов dex определяют Lorg/jetbrains/annotations/TestOnly

Похоже на пробег мельницы 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 реж

1 ответ

Решение

Оказывается, это Funktionale, будучи немного плохим гражданином, который вызывает проблему. Используя поиск класса (Ctrl + N в Windows) для данного класса, я получил два результата. Один из них в ожидаемом пакете аннотаций JetBrains, другой в Funktionale.

Результаты поиска

Глядя на содержимое этого пакета, вы можете увидеть, что он на самом деле содержит целый набор внешних аннотаций:

Содержание дистрибутива Funktionale

Я не могу сказать, почему они сделали это вместо того, чтобы объявить эти библиотеки зависимостями.


Теперь список возможных решений.

  1. Откройте файл.jar, предоставленный зависимостью, удалите из него пакеты, нарушающие работу, перепакуйте его и включите в свой проект как локальный .jar файл.

  2. Посмотрите на хакерские решения, которые пытаются удалить файлы.class из зависимости Gradle. Я нашел это, глядя на это, но, похоже, это не сработало для меня.

  3. Поднимите проблему с авторами библиотеки на GitHub и дождитесь ответа и нового выпуска.

  4. Разложите и повторно опубликуйте библиотеку, удалив пакеты с ошибками.

  5. Вместо этого используйте стрелку. Это новая функциональная библиотека Kotlin, созданная совместными усилиями разработчиков Funktionale и Kategory. Они говорят об этом в эпизоде ​​подкаста Talking Kotlin здесь. К сожалению, у меня нет личного опыта ни с одной из этих библиотек, но она может удовлетворить ваши потребности.

Другие вопросы по тегам