2

Whenever I want to run my project i get the following error

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/design/widget/CoordinatorLayout$1;

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"
    defaultConfig {
        applicationId "com.example.invinciblesourav.flacom"
        minSdkVersion 18
        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'
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}

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'
    compile 'com.google.firebase:firebase-auth:11.0.4'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
    compile 'com.google.firebase:firebase-core:11.0.4'
    compile 'com.google.firebase:firebase-database:11.0.2'
    compile 'com.google.firebase:firebase-storage:11.0.4'
    compile 'com.android.support:design:25.3.1'
    compile 'com.squareup.picasso:picasso:2.4.0'
    testCompile 'junit:junit:4.12'
}


apply pluenter code heregin: 'com.google.gms.google-services'

Please help me.I am stuck in this problem for a few days.

Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49
Sourav Hazra
  • 23
  • 1
  • 4
  • Possible duplicate of [Error:Execution failed for task ':app:transformClassesWithDexForDebug'](https://stackoverflow.com/questions/33717886/errorexecution-failed-for-task-apptransformclasseswithdexfordebug) – Ali Mar 01 '18 at 06:13

5 Answers5

5

I had exactly the same problem. I solve this issue with updating every Google support library to the latest version (27.1.0 in time of writing this solution). Also I updated compileSdkVersion to version 27 and buildToolsVersion to version 27.0.3. I hope that this will solve you problem.

uuzelac
  • 156
  • 1
  • 5
3

just you have to add multidex true and add one dependency to it. check code:

defaultConfig {
    ...
    multiDexEnabled true
}

add dependency:

dependencies {
 compile 'com.android.support:multidex:1.0.1'
}

and if you want to know multidex in details please lokk into below link : https://developer.android.com/studio/build/multidex.html

Happy Coding...

Pratik Satani
  • 1,115
  • 1
  • 9
  • 25
  • 1
    Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/design/widget/CoordinatorLayout$1.class – Sourav Hazra Mar 01 '18 at 06:19
  • target SDK version should not be different then support library so change support.design library version as per target sdk version – Pratik Satani Mar 01 '18 at 06:31
  • and make sure all version on google firebase dependencies version should be same – Pratik Satani Mar 01 '18 at 06:38
  • Now, it requires a gradle upgrade. So, how to accomplish that? – Sourav Hazra Mar 01 '18 at 09:00
2

My issue was related due to the using of different version of same library. One of my sub dependencies was referring to a different version of com.android.support:design, so I forced the version in build.gradle with

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:27.1.0'
        force 'com.android.support:design:27.1.0'
    }
}
0

You should enable multidex property in your build.gradle file

android {

    compileSdkVersion ..
    buildToolsVersion '...'

    defaultConfig {
       ...
       targetSdkVersion ..
       multiDexEnabled true  // this line will solve this problem
   }
}
EKN
  • 1,886
  • 1
  • 16
  • 29
0

Try this ...

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
defaultConfig {
    applicationId "com.example.invinciblesourav.flacom"
    minSdkVersion 18
    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'
    }
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}

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'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-database:11.0.2'
compile 'com.google.firebase:firebase-storage:11.0.4'
compile 'com.android.support:design:25.3.1'
compile 'com.squareup.picasso:picasso:2.4.0'
testCompile 'junit:junit:4.12'
}


apply plugin: 'com.google.gms.google-services'
Mitesh Machhoya
  • 404
  • 2
  • 8