我创建了一个包含以下依赖项的新项目:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'com.squareup.okhttp:okhttp:2.6.0'
implementation 'com.google.code.gson:gson:2.8.2'
}
在运行应用时,我遇到错误:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
可能是什么问题?
答案 0 :(得分:1)
Jaimin,希望您使用..
在app gradle文件中启用了multidexmultiDexEnabled true
如果仍未解决,请添加以下代码:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.+'
}
}
}
}