从最近几个小时开始,我一直在努力解决这个问题。
这些错误是在更新依赖项之后出现的。我在这里遇到的错误是:
Execution failed for task app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
这是我的build.gradle
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.lavazza"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
allprojects {
repositories {
mavenCentral()
}
}
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "2g"
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.3-alpha', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// Glide image library
//SUB-DEPENDENCIES
//Android-Iconics - used to provide an easy API for icons
compile files('libs/httpclient-4.5.3.jar')
compile files('libs/commons-codec-1.9.jar')
compile files('libs/commons-logging-1.2.jar')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.android.support:design:25.4.0'
compile 'com.android.support:recyclerview-v7:25.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:cardview-v7:25.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.volley:volley:1.1.0-rc1'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
compile 'com.android.support:multidex:1.0.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:25.4.0'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.17'
compile 'com.google.android.gms:play-services:11.6.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.5@aar'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.mikepenz:actionitembadge:3.3.1@aar'
compile 'com.mikepenz:iconics-core:2.8.1@aar'
compile 'com.github.rey5137:material:1.2.2'
compile 'com.android.support:mediarouter-v7:25.4.0'
testCompile 'junit:junit:4.12'
}
我已经检查了这个问题的大部分 SO 答案,但对我没有任何帮助。
我已经尝试过以下方法:
1.清理并重建项目。
2.MultidexEnable 已经为真。
3. 使缓存失效并重启Android studio。
在将其标记为重复之前,请为我解决问题。 我被困在这里了。
最佳答案
我遇到了类似的问题,这是我如何解决的:
- 检查 Android Studio 的升级并更新到最新版本。
- 将
实现 'com.android.support:design:27.1.0'
添加到您的应用级 build.gradle 文件中。 - 清理项目然后重建。
希望对您有所帮助!
关于java.lang.RuntimeException : com. android.builder.dexing.DexArchiveMergerException: 无法合并 dex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47260125/