Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/integration/android/IntentResult;

- 74,896
- 15
- 165
- 198

- 780
- 1
- 6
- 11
-
show `build.gradle` – IntelliJ Amiya Sep 05 '17 at 11:32
-
1@IntelliJAmiya This is not a duplicate of the reported question. At least for me, the problem started with AS 3.0 beta 4 and I already use multidex. – ADev Sep 07 '17 at 10:04
-
How? I don't have privileges, I think – ADev Sep 07 '17 at 10:06
-
1@ADev Yes . Thanks for mention . Its a bug ? sure ? – IntelliJ Amiya Sep 07 '17 at 10:10
-
1I don't know yet for sure. But I can run `./gradlew assembleRelease` on the command line without problems. – ADev Sep 07 '17 at 10:12
-
@IntelliJAmiya still not sure if it's a bug but I posted an answer with the solution I found to the problem. – ADev Sep 07 '17 at 10:26
-
Not working in Android Studio 3.0 RC2 – Sagar Trehan Oct 25 '17 at 13:01
-
Try and add this to your gradle file: _multiDexEnabled true_ **It worked for me.** – ManmeetP Nov 02 '17 at 11:10
-
Possible duplicate of [Android MultiDex: an all time salvation is imperative](https://stackoverflow.com/questions/46104198/android-multidex-an-all-time-salvation-is-imperative) (I know it is newer, but it is way better than this error-text-only post!) – NH. Dec 29 '17 at 17:03
15 Answers
I have same problem with Android Studio 3.0 beta 4. I found a solution.
1. From the Build
menu, press the Clean Project
button.
2. After task completed, press the Rebuild Project
button from the Build
menu.

- 764
- 5
- 16
-
-
I wonder, why is the answer not usefull and why report the answer? @SagarTrehan – Y.E.S. Oct 25 '17 at 21:36
-
2This works on Android Studio 3.1 Canary. However it seems like i have to do this each time i make changes to gradle. Is there a lot term fix for this? – Etienne Lawlor Oct 27 '17 at 05:09
-
3
For Android Studio 3.0 what I did was to add this to my gradle:
multiDexEnabled true
And it worked!
Example
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.xx.xxx"
minSdkVersion 15
targetSdkVersion 24
versionCode 9
versionName "1.0"
multiDexEnabled true //Add this
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

- 2,094
- 24
- 30
-
7for me, this does not resolve the problem... I still continue working on resolve it.. – Hpsaturn Nov 01 '17 at 21:41
-
Try these steps: Delete your .gradle, clean and rebuild. Also don't forget add multiDexEnabled. Hope it helps – Prodigy Nov 02 '17 at 00:04
-
If you enable multidex and your minSDK is less than 5.0, then follow the instructions here: https://developer.android.com/studio/build/multidex – Johnny Aug 07 '18 at 22:23
So I solved this issue by doing the following:
- Delete the
./gradle
folder inside your project - Delete all the build folders and the gradle cache. I ran the following command:
How ?
cd ~/[your project root folder] && find . -name build -exec rm -rf {} \; && rm -rf $HOME/.gradle/caches/
Assuming your gradle config files are in the $HOME/.gradle
folder.
- Inside Android Studio, went to
File > Invalidate caches / Restart...
and invalidated the caches and restarted it.

- 74,896
- 15
- 165
- 198

- 5,259
- 2
- 16
- 29
-
2
-
20Same issue on AS 3.0 Beta 7, unfortunately this is still not working for my case. – Kikiwa Oct 05 '17 at 22:44
-
3Have tried all above solution but does not work for AS 3.0 beta 7. Kindly help – Pinkesh Darji Oct 16 '17 at 08:05
-
-
Invalidate caches and restart have broken all my Android Studio settings... – Zon Jan 11 '18 at 16:46
You should be able to get to the cause of this error by inspecting your dependencies with gradle and looking for duplicates like this:
./gradlew -q app:dependencies
In my case, the following error was happening at build time:
Duplicate zip entry [httpcore-4.4.1.jar
and it was resolved by doing this in my build.gradle
:
implementation ('me.dlkanth:stetho-volley:1.0') {
exclude group: 'org.apache.httpcomponents'
}

- 8,197
- 7
- 35
- 50

- 26,189
- 23
- 116
- 147
-
1In my case 'com.android.volley' was being added twice somehow, I also added the exclude statement, now its working fine. – Harish Rana Oct 27 '17 at 10:28
-
running this script gave me `could not determine java version from 9.0.1`. I updated to Gradle from 4.1 to 4.2.1 using Android Studio 3.0 – androidtitan Feb 17 '18 at 23:54
If your minSdkVersion is 21 or higher
android {
defaultConfig {
multiDexEnabled true
}
}
if your minSdkVersion is 20 or lower
1) you must add the following library in dependencies
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
2) Create a java class then extend it from Application and override attachBaseContext method.
public class MyApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
3) Mention the created class inside manifest in application tag.
<application
android:name=".MyApplication"
.
.
.
</application>

- 2,058
- 26
- 24
-
If above code does not work then check your every library in the gradle by holding cursor on it, if it has available new version then Update it, sync, clean project, rebuild project and run. hopefully, it will work for you. – Shahzad Afridi Nov 13 '17 at 12:16
-
This code works for Android 5.1 and above... for below android version.. there is another way to add multidex support. https://developer.android.com/studio/build/multidex.html – Relsell Dec 02 '17 at 10:57
Check your dependencies for latest version usually it is inconsistency with the version of any of your dependencies.
1.Build > Clean Project 2. Rebuild your project
Check the verbose log for the dependency causing the merge issue and update the same. Repeat the same for each dependencies.

- 491
- 8
- 20
I faced same issue in Android Studio 3.0.1, I tried all possible cases nothing worked for me as mentioned above, finally I solved it by
Solution1:
- Close Android Studio
- Delete
.gradle
folder located atC:\Users\YourComputerName\.gradle
not from app's.gradle
- Restart android studio
It will download all the necessary jars and add to your build path
Solution2:
- Delete duplicate jar from libs folder in app/libs
- Rerun the app again
Because if there is duplicate jar file which already defined in build.gradle
file it causes issue.
This solved the issue for me. It may help others..

- 20,649
- 15
- 100
- 138
-
-
Do the same thing which I mentioned in your linux. i.e., Go to terminal the location of .gradle would be something like '~\.gradle\' – Shailendra Madda Dec 01 '17 at 06:07
-
I am trying but its not visible.. Which location you are trying to explain ? Where I installed my Android studio or project location ? – coder_baba Dec 01 '17 at 06:10
-
No it is in your user home i.e., for ex: `~/.gradle/caches/..` – Shailendra Madda Dec 01 '17 at 06:16
-
-
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/160257/discussion-between-shylendra-madda-and-nihal-softy). – Shailendra Madda Dec 01 '17 at 07:33
This error can have multiple reasons. No clean and rebuild or anythging like that did the job for me.
For me the problem was the dependency:
compile 'org.jetbrains:annotations-java5:15.0'
I removed it and everything worked fine.

- 699
- 1
- 6
- 17
In my case the culprit was SendGrid lib, added this and it got fixed:
compile 'com.github.danysantiago:sendgrid-android:1',{
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}

- 1,820
- 1
- 18
- 16
I am using Studio 3.0.0 release. In my case there was the only solution: I have removed old JARs from the "libs" folder in my project: it was "ksoap2" package with dependencies. Packages obtained with gradle usually do not conflict with each other, at least if you are using the most popular ones. But an old JAR in libs folder may crush your build if it includes all own dependencies.

- 920
- 11
- 13
I have tried other comments from removing gradle and bla bla bla, but adding multiDexEnabled true
solving my problem, I investigate that my apk has reached Over 64K Method.
Ref: https://developer.android.com/studio/build/multidex.html)

- 1
- 1

- 356
- 3
- 9
I am using Android Studio 3.0.1 Build #AI-171.4443003, built on November 9, 2017
I delete jar file from libs folder. And that work fine for me

- 192
- 1
- 10
I am using Android Studio 3.0.1 and was facing the same problem. If others answer doesn't works try this:
Tools -> Android -> Sync Project with Gradle Files
It worked for me Sync Project with Gradle Files

- 11
- 2
Sometime it can happens due to same library (jar file) present two times or your project has reached 64k methods limit.
Solution: 1) Remove Databinding if your project use this 2) Remove same type library from lib folder or, delete .gradle file from c//user//your_pc//.gradle 3) apply this in your build.gradle
android {
defaultConfig {
multiDexEnabled true
}
}

- 2,496
- 26
- 27