2

How Can I solve this 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.7.0_67.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

App Build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"


packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/notice.txt'
}

defaultConfig {
    applicationId "com.app"
    minSdkVersion 10
    targetSdkVersion 22
    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' // Do NOT use 22.2.0 even it is newer one. It reported to cause some problems with other dependencies.
compile fileTree(dir: 'libs', include: '*.jar')
compile('com.google.android.gms:play-services:7.5.+')
        {
            exclude module: 'support-v4'
        }
compile group:'com.octo.android.robospice', name:'robospice-spring-android', version:'1.4.7'

compile 'com.octo.android.robospice:robospice-spring-android:1.4.7'

compile group:'org.codehaus.jackson', name:'jackson-mapper-asl', version:'1.9.11'

compile 'com.fasterxml.jackson.core:jackson-databind:2.2.2'

compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.2'

compile 'com.fasterxml.jackson.core:jackson-core:2.2.2'

compile 'com.google.code.gson:gson:2.2.4'

compile 'com.octo.android.robospice:robospice-ormlite:1.4.6'

compile('org.simpleframework:simple-xml:2.7.1') {
//        exclude module: 'xpp3'
//        exclude group: 'stax'
    exclude group: 'xpp3', module: 'xpp3'
    exclude group: 'stax', module: 'stax'
    exclude group: 'stax', module: 'stax-api'
}

}

Project gradle

// 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.2.3'

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

allprojects {
repositories {
    jcenter()
}
}

Android Mainfest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app" >

<!-- Permission - Internet Connect -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

<!-- Permission - Location - GPS Service -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Network State Permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- Call Phone Permissions -->
<uses-permission android:name="android.permission.CALL_PHONE" />

<application
    android:name=".app.AppHelper"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">

    <service
        android:name="com.octo.android.robospice.Jackson2SpringAndroidSpiceService"
        android:exported="false" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyCU__5jhNC-QaU9tXNpr7ikPio3km1UYe8" />

    <activity
        android:name=".ui.splash.SplashActivity"
        android:label="@string/app_name"
        android:noHistory="true"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".ui.base.BaseDrawerFragmentActivity"
        android:configChanges="locale"
        android:label=""
        android:launchMode="singleTask"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme">
    </activity>

</application>

Libs Folder No Libs Folder Exist Now

Valery Viktorovsky
  • 6,487
  • 3
  • 39
  • 47
ahmed Shoeib
  • 254
  • 6
  • 22
  • you have asked this question before (rather than duplicating questions you should put a bounty on the original question): http://stackoverflow.com/questions/29518323/android-studio-com-android-ide-common-process-processexception – Quintin Balsdon Jun 13 '15 at 14:27
  • perhaps you should update your build tools? 21.1.2 is old, there is a 22.0.1 now – eriuzo Jun 13 '15 at 14:28
  • @ Quintin Balsdon it's the same error but with another app with another structure, so i posted it as another question – ahmed Shoeib Jun 13 '15 at 14:32

4 Answers4

5

Welcome. You are at the first step of Android gradle hell.

  1. Update your Android SDK components in SDK Manager to latest one including Extra > Google Repository (recommend to add almost all in Extra).

  2. Let's wash up your current file.

    • AndroidManifest.xml: Remove the <uses-sdk ... /> lines. It's redundant as gradle file already defines it.

    • Build.gradle: Comment all compile files('libs/xxxxxxx.jar') lines. The first line compile fileTree(dir: 'libs', include: ['*.jar']) will include all jar files in libs folder. And, use compile from maven repository not jar files in order to maintain your dependencies fresh.

For example, SimpleXML has repository id as below. Place the code below of the compile fileTree(dir: 'libs', include: ['*.jar']) line and remove 'simple-xml-2.7.1.jar' file in libs folder.

compile('org.simpleframework:simple-xml:2.7.1') {
    exclude module: 'stax'
    exclude module: 'stax-api'
    exclude module: 'xpp3'
}

Likewise, find repository id of each jar file in your libs folder and replace it below of the compile fileTree(dir: 'libs', include: ['*.jar']) line one by one. Make only jar files which unable to find in maven repository remain in libs folder.

Finally, remove proguardFiles line. You need to find and fix the problem in general condition, then apply progruard afterward.

  1. Set version of buildToolsVersion and compileSdkVersion to latest one.

My recommendation of today is as below,
(numbers may vary when someone will see this post in the future)

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'

    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "2g"
    }
    defaultConfig {
        ...
        multiDexEnabled = false
    }
    lintOptions {
        abortOnError false
        disable 'InvalidPackage'
    }

    ...
}


dependencies {
    compile 'com.android.support:appcompat-v7:22.1.1' // Do NOT use 22.2.0 even it is newer one. It reported to cause some problems with other dependencies.
    compile fileTree(dir: 'libs', include: '*.jar')
    compile('com.google.android.gms:play-services-gcm:7.5.+')
        {
            exclude module: 'support-v4'
        }
} 
  1. command gradle assembleDebug again. (for Windows, gradlew assembleDebug)

  2. If failed again, try to find and fix dependencies version conflict issues one by one. You may see exclude module: ... in my code. These resolve the conflict issue. Detailed instruction is given at the link: https://stackoverflow.com/a/30649660/361100

Community
  • 1
  • 1
Youngjae
  • 24,352
  • 18
  • 113
  • 198
  • Youngjae check my updated gradle , removed all libs , but the same error still happen. – ahmed Shoeib Jun 13 '15 at 16:16
  • @ahmedShoeib // remove `proguardFiles` line first. And, did you proceed No. 5 that I recommended? If it is, I recommend you to execute `gradle assembleDebug --stacktrace` and find the problem exactly. You can post failure result of `--stacktrace` or `--info` option. – Youngjae Jun 13 '15 at 17:02
  • the result for command ./gradlew -q dependencies app:dependencies --configuration compile : check this url https://gist.github.com/ahmedshoeib/f433839f392e7a650eaa – ahmed Shoeib Jun 14 '15 at 00:46
  • check the updated gradle and command output here https://gist.github.com/ahmedshoeib/27b0ec30309f787b30f9 – ahmed Shoeib Jun 14 '15 at 01:59
  • @ahmedShoeib // I recommend you to execute gradle with `--debug` (not `--info` sorry above my wrong comment) or `--stacktrace` option. It will show you error causes. – Youngjae Jun 14 '15 at 02:07
  • check the result for ./gradlew --debug : https://gist.github.com/ahmedshoeib/64970f813b1a79f1479f – ahmed Shoeib Jun 14 '15 at 02:27
  • @ahmedShoeib // hey. you got `BUILD SUCCESSFUL` in log. try Build > Clean Project and Rebuild. run `gradlew assembleDebug --debug`. If failed, `gradlew assembleDebug --stacktrace` is better option to diagnose. – Youngjae Jun 14 '15 at 02:41
  • and for command : ./gradlew assembleDebug --stacktrace check this https://gist.github.com/ahmedshoeib/b8001d36a5b7db602fad – ahmed Shoeib Jun 14 '15 at 03:03
  • @ahmedShoeib // You got conflict of support-v4 library. I read your dependencies log and found that you had bad guy `com.google.android:support-v4:r7`. exclude it. I also edit gradle a little for future build error you may got. – Youngjae Jun 14 '15 at 03:04
  • exlude it from where ? – ahmed Shoeib Jun 14 '15 at 03:06
  • @ahmedShoeib // from `org.apache.commons:commons-io:1.3.2` or its mother dependencies `com.octo.android.robospice:robospice-spring-android` – Youngjae Jun 14 '15 at 03:08
  • Thanks alot Youngjae for your support i solved it by removing com.google.android:support-v4:r7 from spring-android and from : compile group:'com.octo.android.robospice', name:'robospice-spring-android', version:'1.4.7' – ahmed Shoeib Jun 14 '15 at 03:20
  • @ahmedShoeib // glad to hear that :) – Youngjae Jun 14 '15 at 03:21
1

Have you tried commenting out the following in your build.gradle:

//compile fileTree(dir: 'libs', include: ['*.jar'])

REFERENCE: https://code.google.com/p/android/issues/detail?id=161605

Quintin Balsdon
  • 5,484
  • 10
  • 54
  • 95
0

Amazingly this one worked for me

defaultConfig {
multiDexEnabled true
}

Source: Android Studio fails to debug with error org.gradle.process.internal.ExecException

Community
  • 1
  • 1
Jaeseok An
  • 58
  • 6
0

The same error occurred to me when I imported all the Google Play Services APIs, as you do with

compile('com.google.android.gms:play-services:7.5.+')

Try removing this line and import only the Services APIs that you need: Google Play Services Setup