Android Studio: Gradle - build failed - execution failed with task: dexDebug '

Mistake:

Gradle: Execution failed for task ':vertretungsplan:dexDebug'. > Failed to run command: P:\Android-Studio\sdk\build-tools\18.0.1\dx.bat --dex --output P:\Projekte\VertretungsplanProject\vertretungsplan\build\libs\vertretungsplan-debug.dex P:\Projekte\VertretungsplanProject\vertretungsplan\build\classes\debug P:\Projekte\VertretungsplanProject\vertretungsplan\build\dependency-cache\debug P:\Android-Studio\sdk\extras\android\m2repository\com\android\support\support-v4\18.0.0\support-v4-18.0.0.jar P:\Projekte\VertretungsplanProject\vertretungsplan\libs\commons-io-2.4.jar P:\Projekte\VertretungsplanProject\vertretungsplan\build\exploded-bundles\VertretungsplanProjectLibrariesActionbarsherlockUnspecified.aar\classes.jar Error Code: 2 Output: trouble processing: bad class file magic (cafebabe) or version (0033.0000) ...while parsing de/MayerhoferSimon/Vertretungsplan/LoginActivity$2.class ...while processing de/MayerhoferSimon/Vertretungsplan/LoginActivity$2.class trouble processing: bad class file magic (cafebabe) or version (0033.0000) ...while parsing de/MayerhoferSimon/Vertretungsplan/MainActivity$1.class ...while processing de/MayerhoferSimon/Vertretungsplan/MainActivity$1.class trouble processing: bad class file magic (cafebabe) or version (0033.0000) ...while parsing de/MayerhoferSimon/Vertretungsplan/YQL/YqlVplanParser.class ...while processing de/MayerhoferSimon/Vertretungsplan/YQL/YqlVplanParser.class 3 warnings UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dx.util.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:592) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:550) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:531) at com.android.dx.merge.DexMerger.mergeDexBuffers(DexMerger.java:168) at com.android.dx.merge.DexMerger.merge(DexMerger.java:186) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:300) at com.android.dx.command.dexer.Main.run(Main.java:232) at com.android.dx.command.dexer.Main.main(Main.java:174) at com.android.dx.command.Main.main(Main.java:91) 

Project Structure:

enter image description here

build.gradle (actionbarsherlock)

 buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android-library' dependencies { compile 'com.android.support:support-v4:18.0.0' } android { compileSdkVersion 18 buildToolsVersion "18.0.1" defaultConfig { minSdkVersion 8 targetSdkVersion 11 } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] res.srcDirs = ['res'] } } } 

build.gradle (vertretungsplan)

 buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android' dependencies { compile files('libs/commons-io-2.4.jar') compile project(':libraries:actionbarsherlock') } android { compileSdkVersion 18 buildToolsVersion "18.0.1" defaultConfig { minSdkVersion 8 targetSdkVersion 11 } } 

settings.gradle

 include ':vertretungsplan', ':libraries:actionbarsherlock' 

How can I fix this error?

+81
android android-studio android-gradle gradle
Aug 02 '13 at 16:29
source share
22 answers

Correct answer: some of your jar files do not compile. You should go into your build.gradle file in your project and look in your dependencies.

If you just import some jar files, you can try to delete them and add them one at a time. This will help you determine which one is causing the error.

In my case, I did just that, and when I imported the latter, the application was compiled. So I think the real problem was that I imported too much at once. But now everything works.

+88
Sep 26 '13 at 7:48
source share

I suddenly had the same problem after any noteworthy changes.

I solved it by deleting the app/build directory and gradle will create a new project.

+65
May 10 '15 at 15:04
source share

You should check if the same JAR is imported again. In my case, there was a class inside the jar that was imported into another jar. So just check if any lib / class file is included in the second project!

+16
Oct 20 '13 at 6:38
source share

I have the same error when I tried to compile the java utils utility file in eclipse using Java JRE 1.8 and use it in my / libs / in Android Studio 1.1.0.

I had Android Studio installed to use JDK1.8.0.

I switched Eclipse to work with JRE 1.7 and the error was fixed. Eclipse: Window-> Preferences-> Java tab-> Compiler -> Compliance Level 1.7. Most likely, you will be asked to switch your JRE library to jdk1.7.x_x.

You may need to disable jar compression when exporting. I did not check if this was an effect or not. I doubt it was connected.

+4
Mar 12 '15 at 17:32
source share

I had the same problem. In my case, the problem started after a reboot. I closed the application, then closed Android Studio (in my case V1.1.0) and finally a normal shutdown. After that, I modified one java file to add a RadioGroup object, and then a problem appeared.

I solved the problem only with changing a simple β€œ0” to β€œ1” in the Gradle configuration file, because the root cause of the problem was generated during the execution of Gradle. I used to have version 1.0.0, then I changed it to "1.1.0", as indicated in the figures.

Gradle configuration location changed Location of the Gradle configuration a changed

The place where I selected the correct version (File -> Settings -> Gradle -> Experimental Location where I took the right version from (File -> Settings -> Gradle -> Experimental

+4
Mar 25 '15 at 21:25
source share

The problem is NOT about Execution failed for task ':dexDebug'

if you look above the error shown in red, you will see this

enter image description here

To solve this problem, just add these lines to your build.gradle file

 android { dexOptions { jumboMode = true } } 

For more information check this question: here

+4
Sep 28 '15 at 20:07
source share

Make sure your AndroidManifest file contains the package name in the node manifest. Setting the package name fixed this problem for me.

+3
Jan 10 '14 at
source share

ANDROID STUDIO users try the following: -

You need to add the following files to your gradle dependencies:

 compile 'com.android.support:multidex:1.0.0' 

Then add the line below (multidex support application) to your application manifest:

 android:name="android.support.multidex.MultiDexApplication" 
+3
Nov 08 '15 at 10:28
source share

Is it possible to fix this by adding

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

for the dependencies in the vertretungsplan build.gradle file, compile and then delete this line and compile again.

now it works

+2
Aug 03 '13 at 1:19 on
source share

I had the same problem you should do:

File -> Invalidate Caches / Restart

+1
Oct 22 '15 at 13:25
source share

I had this problem because I tried to use both the support library and appcompat:

 dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile 'com.android.support:support-v4:23.1.0' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.google.android.gms:play-services:8.3.0' } 

After I removed the support library and changed it to an earlier version, it compiled:

 dependencies { compile fileTree(dir: 'libs', include: '*.jar') /*compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1'*/ compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:design:22.2.0' compile 'com.google.android.gms:play-services:8.3.0' } 
+1
Nov 17 '15 at 12:28
source share

I had two incompatible dependencies.

The dependencies below caused an error.

 compile 'com.google.android.gms:play-services-fitness:8.3.0' compile 'com.google.android.gms:play-services-wearable:8.4.0' 

By changing the fitness dependency to version 8.4.0, I was able to run the application.

 compile 'com.google.android.gms:play-services-fitness:8.4.0' compile 'com.google.android.gms:play-services-wearable:8.4.0' 
+1
Jan 21 '16 at 4:32
source share

I found a very interesting problem with Android Studio and updating mircrosoft in a web browser. I updated "stupidly" to the latest version of ie. Of course, Microsoft, in its infinite wisdom, knows exactly what to do with security. When I tried to compile my application, I continued to receive the error message Gradle - build failed - execution was performed for the task. looking at the stack, I saw that it does not recognize the path to java.exe. I found this strange as soon as I was able to put together the day before. I added JAVA_HOME to env vars for the system, quit Android Studio and reopened it. Low, and now, if the fire wall screen does not tell me if I want all jave.exe through.

What is a cluster!

0
Jun 21 '14 at 17:40
source share

(This might be the wrong thread, as your problem seems more specific, but this is the thread I found when searching for keywords)

Despite all the good hints, the only thing that helped me, and that I would like to share just in case if everything else does not work:

Delete your .gradle directory in your home directory and ask it to reload / reload Android Studio.

All kinds of strange bugs were fixed for me, which were not fixed by reinstalling Android Studio itself and the SDK.

0
Jan 27 '15 at 14:09
source share

The reason may be duplicate libraries after importing from the Eclipse IDE.

 dependencies { compile 'com.github.japgolly.android:svg-android:2.0.5' compile 'com.google.android.gms:play-services:+' compile 'com.android.support:appcompat-v7:21.0.3' compile files('libs/androidannotations-api-2.7.1.jar') compile files('libs/androidasync-2.1.2.jar') //compile files('libs/google-play-services.jar') compile files('libs/universal-image-loader-1.8.2.jar')} 

I had the same problem after a comment:

 //compile files('libs/google-play-services.jar') 

The application does not receive errors.

0
Apr 08 '15 at 13:43 on
source share

I ran into the same problem. Solved by doing this. Go to actionbarsherlock β†’ module settings β†’ dependencies. Remove the v4 support library. At the bottom left there is a plus button, from there add 1 Library Dependency (select support-v4). Allow gradle to run a re-clean project.

0
Jun 07 '15 at 15:43
source share

In my case, I did Build > Clean Project and it will work!

0
04 Oct '15 at 14:35
source share

Many of the answers here are a trial version and an error to find duplicate dependencies, but if you scroll down a bit the line Execution failed for task ':app:dexDebug'. this will give you a hint about duplicates

hint error .

In my case, I had the following error:

 UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define L/com/parse/AbstractQueryController$1; ... ... ... Execution failed for task ':app:dexDebug'. 

So, I knew that to fix this error I need to find duplicate dependencies that define parse.AbstractQueryController

In my case, I had two imported modules that were loaded into two different Parse libraries. Creating my project only loads one fixed my problem.

0
04 Oct '15 at 23:52
source share

I also encountered this error when a package in one of my class files was not written correctly. Many of these answers go straight to Jar files, but I would also check that your packages were written correctly.

0
Nov 02 '15 at 16:20
source share

just add to build.gradle

compile 'com.parse.bolts: bolts-android: 1. +'

compile 'com.parse: parse-android: 1.11.0'

and sync your project with Gradle Files enter image description here But don't add parsing parsing to libs :) OKK

0
Dec 25 '15 at 23:22
source share

If you also use Dagger or Butterknife , you should add guava as a dependency to your main build.gradle file, for example classpath:

com.google.guava:guava:20.0

Otherwise, if you are having problems with a larger heap for the Gradle daemon, you can increase the addition of radle to your file:

  dexOptions { javaMaxHeapSize "4g" } 
0
Mar 09 '17 at 15:21
source share

Cleaning up a project using assembly in the menu bar works for many error scenarios in Android Studio and therefore in this case.

-one
Apr 01 '16 at 16:05
source share



All Articles