简体   繁体   中英

keep getting error Gradle Build failed with an exception : java.exe' finished with non-zero exit value 2 after adding library

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?

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM