2

Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

I'm getting the above exception. I think the problem is in my build.gradle. My build.gradle dependencies is:

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:7.3.0'
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
    compile 'com.getbase:floatingactionbutton:1.9.0'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'me.villani.lorenzo.android:android-cropimage:1.1.0'
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'

}
Inder Kumar Rathore
  • 39,458
  • 17
  • 135
  • 184
aviv_elk
  • 416
  • 1
  • 9
  • 21

2 Answers2

0

This error is due to a limitation of the Dalvik Executable (dex) bytecode file. Because of the number of dependencies in your project you have reached the 65K method limit. Meaning that the Dalvik Executable can only reference 65,536 methods and you have surpassed this limit. These methods includes methods within the Android libraries, any methods within your dependencies and your own methods in which you have written.

To get passed this limitation you can enable multiDex within the build.gradle file which will create more than one Dalvik Executable file.

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        **multiDexEnabled true**
    }
    ...
} 

Before enabling multidex make sure all dependencies are needed. You can use ProGuard http://developer.android.com/tools/help/proguard.html to automatically remove unused dependencies from your build.

bradley4
  • 3,823
  • 6
  • 34
  • 41
0

You can check "libs" folder.

compile fileTree(dir: 'libs', include: ['*.jar'])

This code can import all of the package in "libs".If your "libs" have package,you don't need to compile again.And if you compile 'v7',you can't compile 'v4'.If you "libs" have "v4",delete it.

冯思源
  • 26
  • 4