5

Have tried out the solution on all the following links: Gradle Build Errors

Android Studio Gradle Error - preDexDebug

Android java.exe finished with non-zero exit value 1

finished with non zero exit value

Execution failed for task: ':app:preDexDebug'

http://fqa.io/questions/29045129/android-java-exe-finished-with-non-zero-exit-value-1

http://fqa.io/questions/28933701/android-studio-unable-to-resolve-error-apppredexdebug

The error still remains. Any help will truly be appreciated. Thanks!

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72211Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42211Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:preDexDebug FAILED
Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1

and when i run with --debug option it displays the error as:

Error:05:43:59.724 [ERROR] [org.gradle.BuildExceptionReporter] 
05:43:59.725 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
05:43:59.726 [ERROR] [org.gradle.BuildExceptionReporter] 
05:43:59.727 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
05:43:59.728 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':app:preDexDebug'.
05:43:59.729 [ERROR] [org.gradle.BuildExceptionReporter] > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 1
05:43:59.732 [ERROR] [org.gradle.BuildExceptionReporter] 
05:43:59.733 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
05:43:59.734 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 

And the contents of build.gradle(Project:MyApplication)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Contents of build.gradle(Module:app):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.user.myapplication"
        minSdkVersion 8
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
}
Community
  • 1
  • 1
Vikas Viki
  • 51
  • 1
  • 1
  • 4

5 Answers5

6

I suddenly got the same error and I realized it was happening because of the new Google Play Services library.

I changed this line

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

back to

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

and I can run the app again. As soon as I update to 7.3.0, the problem reappears (every single time).

I'm using Android Studio 1.2, gradle plugin 1.2.2, compileSdkVersion 22, buildToolsVersion 22.0.1.

EyesClear
  • 28,077
  • 7
  • 32
  • 43
1

Try to make sure you keep everything up to date, especially the build tools when building android apps.

Top build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.2' // <-- was 1.1.0

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22 // <-- was 21
    buildToolsVersion "22.0.1" // <-- was 21.1.2

    defaultConfig {
        applicationId "com.example.user.myapplication"
        minSdkVersion 9
        targetSdkVersion 22 // <-- was 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:22.1.1'
}
Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
  • This has been troubling since days!!! Cleaning the project or rebuilding works without errors, but the error occurs when I try to run the project – Vikas Viki Apr 30 '15 at 04:29
  • Do you have the lastest Android sdk and repos downloaded from the Android sdk manager? API 22, latest build tools, etc. – Jared Burrows Apr 30 '15 at 04:37
  • I am not sure. Usually use either the build.grade or missing software. You have all the support and google libs from the sdk manager? – Jared Burrows Apr 30 '15 at 04:46
  • Android SDK tools(24.1.2), Android SDK platform-tools(22), Android SDK build tools(22.0.1), Android 5.5.1_API 22), Android support Repository(14), Android Support Library(22.1.1), Google Repository and Intel x86Emulator Accelator are the ones that are installed. Anything else?? – Vikas Viki Apr 30 '15 at 04:51
1

Try what mark did you say but you keep com.android.tools.build:gradle:1.1.0

Fayçal
  • 1,150
  • 1
  • 12
  • 19
0

I had the same error. I was building the library that was giving me this error with a different SDK build tool. All I had to is right click on that library, for my case "google maps", click on "open module settings", and change the Compile SDK version as well as the build tools version to the same version I'm using for my app directory

Red M
  • 2,609
  • 3
  • 30
  • 50
-1

For my part, i solved this issue by remove incremental true in dexOptions (app/build.gradle).

incremental and multidex is not possible.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Math2T
  • 1
  • 1
  • 2