0

When I try compiling the code, I get the following error:

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_45.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.19.2'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://s3.amazonaws.com/repo.commonsware.com" }

}

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "com.example.example"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 20012
        versionName '2.3.3'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
            proguardFile '/My Workspace/FirstApp/proguard-android.txt'
            debuggable false
            multiDexEnabled true
        }
        debug {
            minifyEnabled false
            debuggable true
            proguardFile '/My Workspace/FirstApp/proguard-android.txt'
        }
    }
    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'LICENSE'
        exclude 'license.txt'
    }
    productFlavors {
    }
}

dependencies {
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.mcxiaoke.volley:library:1.0.18'
    compile 'com.google.code.gson:gson:2.3.1'
    compile files('libs/AF-Android-SDK-v2.3.1.17.jar')
    compile 'com.squareup.okio:okio:1.4.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:cardview-v7:22.2.1'
    compile 'com.android.support:recyclerview-v7:22.2.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:22.2.1'
    compile 'com.commonsware.cwac:anddown:0.2.+'
}

SOLUTION:

Used individual api libraries for google location services / gcm and removed the complete play service library. This reduced the dependable library methods and error got solved.

Govind
  • 2,482
  • 1
  • 28
  • 40

2 Answers2

0

It's too general but, there are a couple of reasons why you get this error

1. Check dependencies{} in build.gradle. There must be duplicate libraries you're depending on.
More details : Check out my website

2. Enlarge heap size in build.gradle while compiling

android {
   ...
   dexOptions{
      incremental true
      javaMaxHeapSize "4g"
   }
}
Daniel Park
  • 268
  • 3
  • 8
  • tried it.. need to add multiDexEnabled true for debug mode too.. but the compile time got increased to 90+ seconds.. – Govind Nov 28 '15 at 10:32
-1

I also faced the same problem when compiling my app but i refered this link https://stackoverflow.com/a/22010135/5594089 it solved my issue.

if (BuildConfig.DEBUG) {
myView.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
        // Do something
    }
});
}

after modifying it like this it will work

View.OnClickListener lClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
    // Do something
}
};

if (BuildConfig.DEBUG) {
      myView.setOnClickListener(lClickListener);
}
Community
  • 1
  • 1
Yasoda
  • 538
  • 5
  • 6