3

I'm unable to run my app. Every time I'm trying to run my app in emulator Android studio shows me following error.

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 2

Here's my build.gradle files.

build.gradle(app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "com.gripxtech.kasim.unipayretailer"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.malinskiy:superrecyclerview:1.1.1'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.codinguser.android:contactpicker:3.0.0@aar'
    compile 'com.squareup.okhttp:okhttp:2.7.0'
    compile project(':materialdatetimepick')
}



build.gradle(Project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}


I've already tried to apply solution from many question similar to mine but, still I can't solve my issue. Thanks in Advance.

Kasim Rangwala
  • 1,765
  • 2
  • 23
  • 44

1 Answers1

5

Add this to build.gradle file:

android {
...
defaultConfig {
    ...
    multiDexEnabled true
    }
}

Here you would find an explanation why this error happened: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define

If it wouldn't work, please delete all files and folders from:

YOUR_APP_NAME\app\build\intermediates

It sometimes happens when you have duplicated dependencies with different versions

Try this command and check if there something twice:

./gradlew dependencies

Hope it help

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94