0

I keep getting below error when i add new library into gradle:

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

This is my gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.1'
    useLibrary 'org.apache.http.legacy'


    defaultConfig {
        applicationId "ir.whc.news"
        minSdkVersion 14
        targetSdkVersion 23

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}


dependencies {


    testCompile 'junit:junit:4.12'
    compile project(":volley")
    compile project(":AndroidBootstrap")
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.android.support:support-annotations:23.1.0'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile 'com.shamanland:fonticon:0.1.9'
    compile 'com.google.android.gms:play-services:8.3.0'
    compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
    compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.github.satyan:sugar:1.4'
    provided 'org.apache.commons:commons-collections4:4.0'


}
apply plugin: 'com.google.gms.google-services'

In the accepted answer of this SO question, There's written that a conflict is the reason of this error. I do not know what is the conflict in my gradle dependency?

Community
  • 1
  • 1
MSepehr
  • 890
  • 2
  • 13
  • 36

2 Answers2

1

I suggest not to compile this as whole as it is, Most of the time this causes over 65K methods dex limit.

compile 'com.google.android.gms:play-services:8.3.0'

see here, Find out the specific one that you really need And use those as per your need for the specific purposes, and it seems you also forgot to add multiDexEnabled true.

Shree Krishna
  • 8,474
  • 6
  • 40
  • 68
  • 1
    i change `compile 'com.google.android.gms:play-services:8.3.0'` to `compile 'com.google.android.gms:play-services-gcm:8.3.0'` and it worked! thank alot – MSepehr Apr 29 '16 at 07:58
0

Include this line inside your defaultConfig:

multiDexEnabled true

Like this:

defaultConfig {
        applicationId "ir.whc.news"
        minSdkVersion 14
        targetSdkVersion 23
        multiDexEnabled true
}

For more info see Building Apps with Over 64K Methods

See this Java finished with non-zero exit value 2 - Android Gradle

Hope it helps you.

Community
  • 1
  • 1
Nongthonbam Tonthoi
  • 12,667
  • 7
  • 37
  • 64