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?
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.
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 :)
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 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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With