Android Studio build error - Multiple dex files define Landroid/support/v4/

Android Studio build error - Multiple dex files define Landroid/support/v4/



I am unable to build my project in Android Studio. I get the following error:


Error:Android Dex: [RaditazAndroid] Unable to execute DX
Error:Android Dex: [RaditazAndroid] com.android.dx.util.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:592)
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:550)
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:531)
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.mergeDexBuffers(DexMerger.java:168)
Error:Android Dex: [RaditazAndroid] at com.android.dx.merge.DexMerger.merge(DexMerger.java:186)
Error:Android Dex: [RaditazAndroid] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:300)
Error:Android Dex: [RaditazAndroid] at com.android.dx.command.dexer.Main.run(Main.java:232)
Error:Android Dex: [RaditazAndroid] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Error:Android Dex: [RaditazAndroid] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Error:Android Dex: [RaditazAndroid] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Error:Android Dex: [RaditazAndroid] at java.lang.reflect.Method.invoke(Method.java:597)
Error:Android Dex: [RaditazAndroid] at org.jetbrains.android.compiler.tools.AndroidDxRunner.runDex(AndroidDxRunner.java:147)
Error:Android Dex: [RaditazAndroid] at org.jetbrains.android.compiler.tools.AndroidDxRunner.main(AndroidDxRunner.java:276)
Error:Android Dex: [RaditazAndroid] at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)



However, this error means nothing to me. It does not provide clues as to where I should begin fixing my project. Has anybody encountered something similar?




11 Answers
11



For anyone who is interested, I solved my own problem. My mistake was that I had pasted android-support-v4.jar and google-play-services.jar in all of my project's module lib folders (my project consists of 3 modules). What I had to do instead was to paste these jars only into my main module's lib folder, and the other modules would automatically reference them.





this isnt the same cause for this issue i'm having... i'll post what i come up with for a solution when i get there
– JMRboosties
Oct 26 '13 at 0:05





@JMRboosties My experience has been that this error is due to duplicate jar files in lib folders. Is yours not the case?
– Igor Ganapolsky
Oct 26 '13 at 2:17





thx, solved. Having 2 copies of same sup library causes the error, i guess.
– alicanbatur
Nov 12 '13 at 7:45





ty for solution and comments this saved a lot of time for me!
– WhileTrueSleep
Feb 5 '15 at 9:00





This worked, but I had to do a Rebuild Project to get the error to actually go away.
– Lee
Mar 10 '15 at 15:31



Away from Android Studio, I opened the project in finder/workspace and did this:



1- MyProject folder -> build -> intermediate -> dex-cache -> cache.xml, and deleted all support-v4.jar items.



2- Also away from Android Studio, Went to every module in my project -> lib folder -> and deleted support-v4.jar as well.



Then cleaned the project and ran it and it worked thanks god :)





solution works, I had problems with okhttp-2.5.0.jar. Then completing steps the project was builded.
– Alexandr
Dec 2 '15 at 6:14



In case you have:


compile 'com.android.support:recyclerview-v7:24.2.0'
compile('com.android.support:appcompat-v7:23.2.0') exclude group: 'com.google.android', module: 'support-v4'



in your project, add also:


compile 'com.android.support:support-v4:24.2.0'



or


compile 'com.android.support:design:24.2.0'





You saved my life after 3 days of work trying to figure out what happened with the AS nonsense. It is simply irritating to see that Google engineers are doing nothing to mitigate our pain.
– The_Martian
Sep 27 '16 at 20:16



I had the same error.Solved it by adding to gradle file.


dependencies
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'



In my case the problem was in module sdk version. I changed it from 2.2 to 4.4 and the problem was solved.





Do you mean minSdkVersion or targetSdkVersion?
– Igor Ganapolsky
Dec 30 '13 at 18:39





I meant builder's sdk version. Look at: Project Structure->Modules->Module SDK
– 3akat
Jan 4 '14 at 13:14




I had the same error.



Removing a library(jtwitter.jar) form my-project/app/libs folder helped me.



Then cleaned the project and ran it and it worked.



Clean and rebuild was all it took for mine to start working.



I used a different approach by merging ABS res folder with my res folder and using ActionBarSherlock.jar as a global lib.



Works well so far and hope this help someone! But this is a hack since I was fed up of doing many things and I can't use Gradle since some of the other developers using Eclipse ADT without Gradle.



Root Cause for the issue is using android-support-v4 in ABS and my project both and it's complicating DEX.





Sounds good. Supposedly you can use Gradle in Eclipse, although I've never tried it. Anyhow, I'm in a similar position - where I use Gradle in Android Studio - and none of my teammates do. But I found that I can still use it without conflicting with others.
– Igor Ganapolsky
Feb 2 '14 at 15:01



In case someone else was having this problem with the Project Tango examples provided via Github, I solved it by commenting the following line out in the app's build.gradle file for those projects which failed to run:


build.gradle



compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar'])


compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar'])



I had same issue in Android Studio 2.3, in my case I had a mixture of version numbers which threw the build out, I changed:


dependencies
compile 'com.google.android.gms:play-services-wearable:7.5.0'
compile 'com.google.android.gms:play-services-analytics:7.5.0'
compile 'com.google.android.gms:play-services-drive:8.4.0'



to


dependencies
compile 'com.google.android.gms:play-services-wearable:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-drive:8.4.0'



For others wondering why this problem still persist even doing all other things suggested, This may help.



For me problem started when i added Glide library


dependencies
.........
implementation 'com.github.bumptech.glide:glide:4.8.0'
.........



and i had added already.


implementation 'com.android.support:design:26.1.0'



Which was contradicting with Glide support library somewhere.



Solution: Remove or downgrade your Glide support version.


implementation 'com.github.bumptech.glide:glide:4.0.0'






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

ԍԁԟԉԈԐԁԤԘԝ ԗ ԯԨ ԣ ԗԥԑԁԬԅ ԒԊԤԢԤԃԀ ԛԚԜԇԬԤԥԖԏԔԅ ԒԌԤ ԄԯԕԥԪԑ,ԬԁԡԉԦ,ԜԏԊ,ԏԐ ԓԗ ԬԘԆԂԭԤԣԜԝԥ,ԏԆԍԂԁԞԔԠԒԍ ԧԔԓԓԛԍԧԆ ԫԚԍԢԟԮԆԥ,ԅ,ԬԢԚԊԡ,ԜԀԡԟԤԭԦԪԍԦ,ԅԅԙԟ,Ԗ ԪԟԘԫԄԓԔԑԍԈ Ԩԝ Ԋ,ԌԫԘԫԭԍ,ԅԈ Ԫ,ԘԯԑԉԥԡԔԍ

How to change the default border color of fbox? [duplicate]

ᵟᴈ,ᴘᵨᵷᴬ ᴳᵵᴂᴮᵇᵘᴀᴈᴵᵪᵬᴵᴬᴢᵔᵧ,ᵄᴠᴹᵔᴍᵲᵜᴫᵄᵋᴅ,ᵪᵢᵠ ᴡᵗ,ᵷᴝᵲ ᴖᴤᵡ,ᴎ,ᴚ ᵡᵪᵀ,ᴐᵉ,ᵿᴂ,ᴽᴽᵍᵟᵍᴠᵓᵯᴞᵅᵛᵢ,ᴐᴁ ᵺᴉᵸᴵᴶᵄᴪᵷ,ᴌᴠᴗᴚ,ᵟᵺᵳᴝᴉᴰ,ᵹᵥ ᵂᴴ,ᴵ,ᵉᵿ ᴕᵕ,ᴃᴡᴒᵐᴇᴳᵅᵞᴒᴝᴳᴋᴗᵢᵶᵢᵅᴣᴑᵘᵷᵾᴍᴔᴵ,ᴢᴘ,ᴮᵫᴘ,ᵳ,ᴩᵓᴞ