0

//Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;

  apply plugin: 'com.android.application'

      android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
    applicationId "com.cpsraozan.admission"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
 'proguard-rules.pro'
    }
    }

     }

       dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
 androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
         {
        exclude group: 'com.android.support', module: 'support-annotations'
       })
       compile 'com.android.support:appcompat-v7:27.+'
     compile 'com.android.support.constraint:constraint-layout:1.0.2'
      testCompile 'junit:junit:4.12'
      compile 'com.google.firebase:firebase-messaging:9.4.0'
                compile 'com.google.firebase:firebase-core:9.4.0'

       }
      apply plugin: 'com.google.gms.google-services'
Zoe
  • 27,060
  • 21
  • 118
  • 148
Shah Alam
  • 11
  • 2

2 Answers2

1

Go to your build.gradle file and add multidexEnable true on defaultConfig.

android {

    compileSdkVersion 26

    defaultConfig {
       targetSdkVersion ..
       multiDexEnabled true  //add this
   }
}

For more information See this

Vihanga Yasith
  • 328
  • 5
  • 18
  • try theses answers. [this](https://stackoverflow.com/questions/33369163/execution-failed-for-task-apptransformclasseswithdexfordebug-while-implement) – Vihanga Yasith Dec 01 '17 at 16:58
  • try [this](https://stackoverflow.com/questions/33717886/errorexecution-failed-for-task-apptransformclasseswithdexfordebug) also – Vihanga Yasith Dec 01 '17 at 16:58
0

This is kind of NOT straight forward. Most likely you might have added a new dependency or updated a dependency which is causing multiple versions of the same library being added as a dependency.

  1. Check if Android studio is highlighting any lines for this, especially in Gradle files.

  2. Run a dump of all dependencies Gradle is processing using the command

    ./gradlew -q dependencies app:dependencies

check for conflicting dependencies and fix them.

I was struggling this morning with the same error and the requirement for multiDexEnabled didn't make sense. This is only for large projects with more than 64k methods. I found this solution somewhere on SO, but couldn't find it again. So reposting the answer.

Community
  • 1
  • 1
Bhuvan
  • 1,523
  • 4
  • 23
  • 49