How to fix "Execution failed for task ':app:transformClassesWithDexForRelease' in Android Studio?
Last Updated :
24 Mar, 2021
When we run our app in debug mode in Android Studio, it runs successfully but when we switch to release mode, it fails and throws the error:
**FAILURE: Build failed with an exception.**
> Execution failed for task ':app:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
So, In this article, we will discuss 6 different methods for fixing the “Execution failed for task ':app:transformClassesWithDexForRelease” error in Android Studio.
Method 1
We can fix this error by adding few lines of code in the "local.properties" file and also in "gradle" file.
In local.properties (The local.properties file goes in the project's root level),
org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
and, in gradle file, you should do this changes and this will help you in resolving this error.
defaultConfig {
applicationId "yourProjectPackage"
minSdkVersion 15
versionCode 1
versionName "1.0"
targetSdkVersion 23
multiDexEnabled true //important
}
Method 2
This error "Execution failed for task ':app:transformClassesWithDexForRelease" in Android Studio can also be resolved after the removal of jar file from your project which seems that one of the jar files inside your project was using an older version of google play services.
Method 3
If you make multiDexEnabled = true in defaultConfig of the app (Gradle File), you will be able to resolve this error.

defaultConfig {
minSdkVersion 14
targetSdkVersion 22
multiDexEnabled = true
}
Method 4
We can also resolve this issue by following these steps:
- Step 1: Open your app's build.gradle (not the one in the project root).
- Step 2: Add this Code Snippet.
android {
// snippet
// add this into your existing 'android' block
dexOptions {
javaMaxHeapSize "4g"
}
// snip
}
Note: 4g is 4 Gigabytes and this is a maximum heap size for dex operation.

- Step 3: Try your build again.
Method 5
Another issue that could be causing this may be some sort of external library you are using, that is referencing a prior version of your dependency. Follow these steps in that case:
- Go to SDK manager, and install any updates to your dependencies

Method 6
This error "Execution failed for task ':app:transformClassesWithDexForRelease' in Android Studio can also occurred when we upgrading Google play services to 9.0 from 7.5. So, to resolve this--
Change this code snippet:
compile 'com.google.android.gms:play-services:7.5.0'
to
compile 'com.google.android.gms:play-services:9.0.0'
Similar Reads
Different Ways to fix "Execution failed for task ':app:clean'. Unable to delete file" error in Android Studio When you try to rebuild or clean and build your project (containing mostly Kotlin code) in Android Studio, it fails and throws the error: Execution failed for task ':app:clean'. Unable to delete file: SpecificFileLocation So, In this article, we are going to see the topics: why there is a need to so
3 min read
Fix "Execution failed app:processDebugResources" in Android Studio Resources are the files and static content that the application's code uses, such as animations, images, layouts, and string values. These files stored in the resource directory can be referenced from the application's code but when a non-existent reference is called android throws an "Execution fai
3 min read
How to Fix Gradle: Execution failed for task ':processDebugManifest' Error in Android Studio? Gradle assemble-info provided me an indication that the manifestations do not have various versions of SDK and can not be integrated. And after hours of working on some important project you suddenly face such an issue: Firgure1. Oops! Well, getting rid of this is easy, just follow the below-mention
3 min read
How to fix Could not find folder 'tools' inside SDK in Android? There are many IDEs available for developing android development. Many developers prefer using Eclipse as an IDE for building android applications. While using Eclipse IDE for android development many times we will get to see an error message as Could not find folder tools inside SDK folder. In this
3 min read
How to Convert Any Website to Android App in Android Studio? Here, we are going to make an application for the "Wikipedia" website. By making this application we will be able to learn how we can convert a website to an Android Application just by following simple steps. You can use this concept for your personal website too and learn something new.Step by Ste
2 min read