gpt4 book ai didi

android - 多个dex文件定义Landroid/support/test/espresso/accessibility/R$attr;

转载 作者:行者123 更新时间:2023-11-29 02:35:37 24 4
gpt4 key购买 nike

尝试运行 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'
  • Espresso 3.0.1

请指教

最佳答案

通过强制特定库版本解决了这个问题:

   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'
}
}

并使用这个 gradle 命令查看依赖关系树:

./gradlew -q dependencies :project_name:dependencies

关于android - 多个dex文件定义Landroid/support/test/espresso/accessibility/R$attr;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47317384/

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