4

I am trying to execute the code but i'm getting error message in messages gradle build that

Execution failed for  task ':app:transformClassesWithDexForDebug'.
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\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 2

build.gradle(app module) of my project is.

  apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.paulusworld.drawernavigationtabs"
        minSdkVersion 15
        targetSdkVersion 23
    /*    multiDexEnabled true*/
    }

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/android-support-v23.jar')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
}


build gradle(project navigationtab)


buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}
Abhinav singh
  • 1,448
  • 1
  • 14
  • 31
Fatal Exception
  • 167
  • 2
  • 12

2 Answers2

0

Having the 'multiDexEnabled' set to 'true' would be a quickfix that could work, but it would also hide the real problem. Consider reviewing your application setup, like the libraries you're including in your project, they might be adding more than you need...

Have a look on what you have on your libs directory, as your gradle is adding all the jars there. And what's this in comparison to the v4 & v7 compile entries?

compile files('libs/android-support-v23.jar')

Also, if you add the appcompat-v7 you don't need to add the support-v4 for instance.

Read this section Avoiding the 65K Limit for further details.

Alécio Carvalho
  • 13,481
  • 5
  • 68
  • 74
-1
buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'
}
}

allprojects {
repositories {
    jcenter()
}
}

These has to be in project level gradle file if I am not wrong

Uncomment multiDexEnabled true and you are good to go!!

johnrao07
  • 6,690
  • 4
  • 32
  • 55
  • 1
    hey john thanks for your prompt response. if i would uncomment multiDexEnabled true . i am getting another error message i.e Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/util/MapCollections$ArrayIterator.class – Fatal Exception Nov 25 '15 at 10:28
  • yeah you are quite right John, mistakenly i wrote build(NavigationDrawer) instead of project(NavigationDrawer). – Fatal Exception Nov 25 '15 at 11:20