尝试运行UI测试(androidTest)后,我一直收到以下错误
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/test/espresso/accessibility/R$attr;
Error:Execution failed for task ':chegg-study:transformDexArchiveWithDexMergerForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Landroid/support/test/espresso/accessibility/R$attr;
AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: com.android.dex.DexException: Multiple dex files define Landroid/support/test/espresso/accessibility/R$attr;","sources":[{}],"original":"UNEXPECTED TOP-LEVEL EXCEPTION:\ncom.android.dex.DexException: Multiple dex files define Landroid/support/test/espresso/accessibility/R$attr;\n","tool":"Dex"}
AGPBI: {"kind":"error","text":"com.android.dex.DexException: Multiple dex files define Landroid/support/test/espresso/accessibility/R$attr;","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:198)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)","sources":[{}]}
AGPBI: {"kind":"error","text":"\tat java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)","sources":[{}]}
我的gradle包含以下依赖项:
androidTestImplementation "com.android.support.test.espresso:espresso-core:$espresso"
androidTestImplementation "com.android.support.test.espresso:espresso-contrib:$espresso"
androidTestImplementation "com.android.support.test.espresso:espresso-intents:$espresso"
androidTestImplementation "com.android.support.test.espresso:espresso-accessibility:$espresso"
androidTestImplementation "com.android.support.test.espresso:espresso-web:$espresso"
androidTestImplementation "com.android.support.test.espresso:espresso-idling-resource:$espresso"
androidTestImplementation "com.android.support.test.espresso.idling:idling-concurrent:$espresso"
androidTestImplementation 'com.android.support:multidex-instrumentation:1.0.2'
请告知
答案 0 :(得分:0)
通过强制特定的libs版本解决了这个问题:
class Child
并使用此gradle命令查看依赖项树:
configurations.all {
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
// e.g. multiple different versions of the same dependency (group and name are equal)
failOnVersionConflict()
// prefer modules that are part of this build (multi-project or composite build) over external modules
preferProjectModules()
force 'com.android.support:appcompat-v7:27.0.1'
}
}