报错如下:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
项目中出现的原因
同一个依赖项目,多次compile,导致merge dex 失败
具体是这样
compile('com.github.afollestad.material-dialogs:core:0.8.5.2@aar') { transitive = true }
然后又依赖同一项目的top version导致
compile 'com.afollestad.material-dialogs:core:0.9.5.0'
要其一即可
还有top version 使用了高compileSDK
要在project的build.gradle加入最新的sdk高版本脚本,强制所有module一律使用高版本
configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '27.0.0' } } } }