问题描述
我收到了可怕的java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
错误.堆栈跟踪将根本原因显示为:
I get the dreaded java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
error. The stack trace shows the root cause as:
Caused by: com.android.dex.DexException: Multiple dex files define Landroid/support/v7/recyclerview/extensions/ListAdapter;
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)
根本原因是什么?
推荐答案
最有可能,您正在尝试使用以下两个依赖项:
Most likely, you are attempting to use these two dependencies:
implementation "android.arch.paging:runtime:1.0.0-alpha5"
implementation "com.android.support:recyclerview-v7:27.1.0"
冲突的类(android.support.v7.recyclerview.extensions.ListAdapter
)从分页runtime
移到了recyclerview-v7
...,但是只有分页runtime
中的1.0.0-alpha6
或更高版本.使用1.0.0-alpha5
和支持库的27.1.0
,您将在两个地方得到相同的类.
The conflicting class (android.support.v7.recyclerview.extensions.ListAdapter
) moved to recyclerview-v7
from the Paging runtime
... but only with 1.0.0-alpha6
or higher of the Paging runtime
. With 1.0.0-alpha5
, coupled with 27.1.0
of the Support Library, you get the same class in both places.
相反,请迁移至:
implementation "android.arch.paging:runtime:1.0.0-alpha6"
implementation "com.android.support:recyclerview-v7:27.1.0"
这篇关于为什么我要获取“多个dex文件定义Landroid/support/v7/recyclerview/extensions/ListAdapter"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!