Error:Execution failed for task ':app:transformClassesWithDexForDebug' in android studio
Solution 1
Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
The upper error occure due to lot of reason. So I can put why this error occure and how to solve it.
REASON 1 : Duplicate of class file name
SOLUTION :
when your refactoring of some of your class files to a library project. and that time you write name of class file So, double check that you do not have any duplicate names
REASON 2 : When you have lot of cache Memory
SOLUTION :
Sometime if you have lot of cache memory then this error occure so solve it.
go to File/Invalidate caches / Restart
then select Invalidate and Restart
it will clean your cache memory.
REASON 3 : When there is internal bug or used beta Version to Switch back to stable version.
SOLUTION :
Solution is just simple go to Build menu and click Clean Project
and after cleaning click Rebuild Project
.
REASON 4 : When you memory of the system Configuration is low.
SOLUTION :
open Task Manager and stop the other application which are not most used at that time so it will free the space and solve OutOfMemory
.
REASON 5 : The problem is your method count has exceed from 65K.
SOLUTION :
open your Project build.gradle
file add
defaultConfig {
...
multiDexEnabled true
}
and in dependencies add below line.
dependencies
{
compile 'com.android.support:multidex:1.0.0'
}
Solution 2
**In my case problem solved with Instant Run DISABLE **
Solution 3
Check Whether multidex enabled or not in your build.gradle(app level) under dependencies.if not place like below
dependecies{
multidexEnabled true
}
Check your gradle.properties(app level).if you see the below code
#org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
remove # before the line ,then it should be like this
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Solution 4
Please Add this into your gradle file
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
AND also add the below dependency in your gradle
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
OR another option would be: In your manifest file add the MultiDexApplication package from the multidex support library in the application tag.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Solution 5
This can be because of following reason:
one of the jar files inside project was using an older version of google play services.
use
multiDexEnabled true
indefaultconfig
Be specific with classes you add in dependencies. like
compile 'com.google.android.gms:play-services-maps:8.4.0'
Not like compile 'com.google.android.gms:play-services:+'
user1938357
Updated on July 12, 2022Comments
-
user1938357 almost 2 years
I am moving my projects from eclipse to Android Studio. While running one of my app I get the following error. Not able to find any solution. I have enabled multidex as well.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
also my gradle file is below
apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.myapp" minSdkVersion 9 targetSdkVersion 21 multiDexEnabled true }buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard- android.txt'), 'proguard-project.txt', 'proguard-google-api-client.txt' } } } dependencies { compile 'com.android.support:support-v4:23.4.0' compile 'com.google.android.gms:play-services:+' compile 'com.google.http-client:google-http-client-gson:1.20.0' compile 'com.google.code.gson:gson:2.1' compile 'com.android.support:appcompat-v7:23.4.0' compile files('libs/activation.jar') compile files('libs/additionnal.jar') compile files('libs/android-support-v7-cardview.jar') compile files('libs/android-support-v7-recyclerview.jar') compile files('libs/commons-logging-1.1.1.jar') compile 'com.google.api-client:google-api-client:1.18.0-rc' compile 'com.google.api-client:google-api-client-android:1.18.0-rc' compile 'com.google.api-client:google-api-client-appengine:1.18.0-rc' compile 'com.google.http-client:google-http-client:1.18.0-rc' compile 'com.google.http-client:google-http-client-android:1.18.0-rc' compile 'com.google.http-client:google-http-client-appengine:1.18.0-rc' compile 'com.google.oauth-client:google-oauth-client:1.18.0-rc' compile 'com.google.oauth-client:google-oauth-client-appengine:1.18.0-rc' compile files('libs/google-api-client-gson-1.18.0-rc.jar') compile files('libs/google-api-client-jackson2-1.18.0-rc.jar') compile files('libs/google-api-client-java6-1.18.0-rc.jar') compile files('libs/google-api-client-servlet-1.18.0-rc.jar') compile files('libs/google-http-client-jackson2-1.18.0-rc.jar') compile files('libs/google-http-client-jdo-1.18.0-rc.jar') compile files('libs/google-oauth-client-java6-1.18.0-rc.jar') compile files('libs/google-oauth-client-jetty-1.18.0-rc.jar') compile files('libs/google-oauth-client-servlet-1.18.0-rc.jar') compile files('libs/GraphView-4.0.1.jar') compile files('libs/httpclient-4.0.1.jar') compile files('libs/httpcore-4.0.1.jar') compile files('libs/jackson-core-2.1.3.jar') compile files('libs/jetty-6.1.26.jar') compile files('libs/jetty-util-6.1.26.jar') compile files('libs/jsr305-1.3.9.jar') compile files('libs/jxl.jar') compile files('libs/mail.jar') compile files('libs/transaction-api-1.1.jar') }
-
Nils over 7 yearsif you have already add multiDexEnabled true then REASON-2 is help you. Thanks @Ironman , its help me.
-
Harshad Pansuriya over 7 years@Nils glad to know that.
-
Leos Literak over 7 yearsHow can I find methods count?
-
Leos Literak over 7 yearsI had to uncomment org.gradle.jvmargs in graddle.properties
-
KJEjava48 about 7 yearsthanks @Ironman for pointing out these solutions.Some times I am getting this error even if i have multiDexEnabled true, solution 2 help on that case.Otherwise I need to restart my machine to solve this.
-
Shn almost 7 yearsCleaning the project worked for me. I restarted both my computer and phones several times and rebooted android studio and nothing helped except cleaning >.<
-
Peter Fortuin almost 6 yearsDowngrading the sdkversion is a bad idea. The Google Play Store even require you to up you sdkversion in the future.
-
Ali Nawaz almost 6 yearsinvalidate cache and restart worked for me... guys do this option very first try... Thanks
-
Malwinder Singh almost 5 yearsAndroid 5.0 (API level 21) and higher uses ART which natively supports multidexing. Therefore, if your
minSdkVersion
is 21 or higher, the multidex support library is not needed. -
Travis Delly almost 5 yearsExecution failed for task ':app:transformClassesWithMultidexlistForDebug'.