org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:app:transformClassesWithDexForDebug’

We Are Going To Discuss About org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:app:transformClassesWithDexForDebug’. So lets Start this Java Article.

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:app:transformClassesWithDexForDebug’

  1. org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexForDebug'

    Check build.gradle(Module: Android) fixed problem for me.
    Modify it to workable version.
    android { buildToolsVersion '23.0.1' }

  2. org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexForDebug'

    Check build.gradle(Module: Android) fixed problem for me.
    Modify it to workable version.
    android { buildToolsVersion '23.0.1' }

Solution 1

Check build.gradle(Module: Android) fixed problem for me.

Modify it to workable version.

android {
    buildToolsVersion '23.0.1'
}

Original Author Beatrice Lin Of This Content

Solution 2

Just a simple solution is here…it worked for me:

  1. Clean Project
  2. Rebuild project
  3. Sync project with gradle file

Original Author PRIYA Of This Content

Solution 3

the steps I followed are:

  1. close Android Studio (or IntelliJ IDEA)
  2. in your project’s directory:
    1. delete .idea directory
    2. delete .gradle directory
    3. delete all .iml files
      • find . | grep -e .iml$ | xargs rm
  3. use Android Studio to re-open the directory as a project

Terminal commands:

# close Android Studio
cd "your project's directory"
rm -rf ./.idea
rm -rf ./.gradle
find . | grep -e .iml$ | xargs rm
# use Android Studio to re-open the directory as a project

Original Author Eric Of This Content

Solution 4

I had the same issue and I could solve it like this:

1) If your minSdkVersion is set to 21 or a higher value, the only thing you need to do is to set multiDexEnabled in your build.gradle file at the module level, as shown below:

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 28
        multiDexEnabled true
    }
    ...
}

2) However, if your minSdkVersion is set to 20 or less, you should use the MultiDex compatibility library, as follows:

2.1) Modify the module-level build.gradle file to enable MultiDex and add the MultiDex library as dependency, as shown below

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 28
        multiDexEnabled true
    }
    ...
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
}

2.2) According to the Application class or not, do one of the following actions:

2.2.1) If you do not cancel the Application class, modify your manifest file to set android: name in the <application> tag as shown below:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>

2.2.2) If you cancel the Application class, you must change it to extend MultiDexApplication (if possible) as shown below:

public class MyApplication extends MultiDexApplication { ... }

2.2.3) Also, if you override the Application class and can not change the base class, alternatively you can override the attachBaseContext () method and invoke MultiDex.install (this) to enable MultiDex:

public class MyApplication extends SomeOtherApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

Please use this link, it was really useful for me!

Original Author esterrrsinH Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment