1 September 2014

How to solve problem with error:Error:Execution failed for task ':dexDebug'. > com.android.ide.common.internal.LoggedErrorException: Failed to run command: Android Studio\sdk\build-tools\android-4.4W\dx.bat

Solution for Android Studio 0.8.6, Gradle 1.12

ERROR:
Error:Execution failed for task ':dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Programs\Android Studio\sdk\build-tools\android-4.4W\dx.bat --dex --num-threads=4 --output D:\Dropbox\dsProjects\dsDiagnosticTools\build\intermediates\dex\debug
(...)
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)

STORY:
I love IntellIJ IDEA.It is best IDE. I was delighted, when Google decided to switch from most crappy Eclipse to awesome IntelliJ IDEA.
It makes my Android Studio development enjoyable.
My only problem is Gradle. I wanted to learn Gradle  3 times but I wasted lost of my free time and I didn't achieve anything as it cause lots of problems and hacks to make something to work.
When Google decided move Admob SDK to Google Play Services ,I decided to try use Gradle in Android Studio and ... so far is total disaster.
Anyway...

SOLUTION:

I saw this error in all my android projects that was created in IntelliJ IDEA and used  android-support-v4 library that was imported to libs folder.
Simply delete android-support-v4 library from libs folder and ...It will works.

(Problem appear all project that was migrated to Gradle project)