android project: process finished with non-zero ex

2019-01-25 10:01发布

I'm unable to compile my android project. Google and other SO posts tell me it (probably) has something to do with dependencies, but I can't find where. Here's the error:

Error:Gradle: Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2

and my gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.skate.socialskate"

        minSdkVersion 21
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.android.gms:play-services:7.3.0'
    compile 'com.google.apis:google-api-services-youtube:v3-rev136-1.20.0'
    compile 'com.android.support:cardview-v7:22.1.0'
    compile 'com.android.support:recyclerview-v7:21.0.+'
    compile 'de.hdodenhof:circleimageview:1.2.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+'
    compile 'com.fasterxml.jackson.core:jackson-core:2.2.+'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+'
    compile 'org.jsoup:jsoup:1.8.2'
    compile 'com.github.shell-software:fab:1.1.0'
    compile 'com.google.api-client:google-api-client:1.18.0-rc'



}

5条回答
叼着烟拽天下
2楼-- · 2019-01-25 10:39

This happened for me when I was refactoring some class files to a library project and I had a duplicate name of a class file. So, double check that you do not have any duplicate names.

查看更多
趁早两清
3楼-- · 2019-01-25 10:46

In my case I write in the build.gradle dependencies from the parse quick guide

dependencies{
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
}

then I replace with

dependencies {
    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
}

Save the changes, restart the android studio and run the project. It worked in my case.

查看更多
走好不送
4楼-- · 2019-01-25 11:02

I have used this command in build.gradle file.

configurations {
all*.exclude group: 'com.android.support', module: 'support-v4'
}

It has resolved this "non-zero-exit-value" and another one 'duplicate entry during packageAllDebugClassesForMultiDex'.

查看更多
闹够了就滚
5楼-- · 2019-01-25 11:03

Android Studio suggests,

Avoid using + in version numbers can lead to unpredictable and unrepeatable builds.

+ in dependencies lets you pick up automatically the latest available version rather than a specific one, however this is not recommended.

You may have tested with a slightly different version than what build server used.

After Removing Plus Sign and Adding a Specific Version problem was solved in my case.

查看更多
SAY GOODBYE
6楼-- · 2019-01-25 11:05

The date of when this happened to me was 07/08/2016.

I just got this exact error after updating to the newest android studio.

I resolved it by updating my java jdk from java jdk 7 to java jdk 8.

Now my builds work fine. I think the newest version of android studio requires jdk 8…

查看更多
登录 后发表回答