依赖性问题:DexArchiveMergerException
Dependency Issue : DexArchiveMergerException
我创建了一个包含以下依赖项的新项目:
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
可能是什么问题?
Jaimin,希望您已在您的应用程序 gradle 文件中启用 multidex 使用..
multiDexEnabled 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.+'
}
}
}
}
我创建了一个包含以下依赖项的新项目:
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
可能是什么问题?
Jaimin,希望您已在您的应用程序 gradle 文件中启用 multidex 使用..
multiDexEnabled 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.+'
}
}
}
}