1

I am facing this runtime error.It says :

Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2

Here is my build.gradle script :

apply plugin: 'com.android.application'

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

defaultConfig {
    applicationId "com.stratbeans.barium.mobilebarium"
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile files('libs/universal-image-loader-1.9.3.jar')
compile files('libs/listviewanimations_lib-core-slh_3.1.0.jar')
compile project(':ListViewAnimations-core')
compile project(':StickyListHeaders')
compile project(':ListViewAnimations-core-slh')

Please help me out.Thanks!

Sid
  • 435
  • 4
  • 9
  • 19

2 Answers2

1

You should audit your project for unwanted dependencies and remove as much unused code as possible using ProGuard.

  1. Change your Gradle build configuration to enable multidex
  2. Modify your manifest to reference the MultiDexApplication class

Modify your app Gradle build file configuration to include the support library and enable multidex output .

    android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
       applicationId "com.stratbeans.barium.mobilebarium"
       minSdkVersion 16
       targetSdkVersion 23
       versionCode 1
       versionName "1.0"

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

For details you can visit my answer DexIndexOverflowException Only When Running Tests

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • Tried this too, the same error keeps coming up. It goes when I comment this line "compile project(':ListViewAnimations-core')". But without this the google cards list view that I am trying to implement in my app won't work properly. – Sid Nov 09 '15 at 10:27
  • okay .Comment out (I mean remove this line and see the result) `compile project(':ListViewAnimations-core')` – IntelliJ Amiya Nov 09 '15 at 10:34
  • Why would that make any difference? – Sid Nov 09 '15 at 10:38
0
defaultConfig {
     multiDexEnabled true 
}

Add multiDexEnabled true inside your defaultConfig in your build.gradle.
Hope that will work for you!

AnswerDroid
  • 1,873
  • 2
  • 33
  • 52
  • And add this line in dependencies : compile 'com.android.support:multidex:1.0.1' AND You have to add this in the android-manifest : android:name="android.support.multidex.MultiDexApplication" in – Jey10 Nov 09 '15 at 09:21
  • It gave me this error on adding the above lines "Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'. > java.util.zip.ZipException: duplicate entry: android/support/v4/widget/SearchViewCompatIcs$MySearchView.class" – Sid Nov 09 '15 at 09:32
  • This means one of the dependencies added is duplicate, search it ,remove it clean and rebuild project – AnswerDroid Nov 09 '15 at 09:38
  • This dependency is causing the problem "compile project(':ListViewAnimations-core')". But I need to include it in my app or I won't have the functionality that I want. – Sid Nov 09 '15 at 10:29
  • compile files('libs/listviewanimations_lib-core-slh_3.1.0.jar') compile project(':ListViewAnimations-core') compile project(':StickyListHeaders') compile project(':ListViewAnimations-core-slh') Do you require all 4 of those? It may be repeating internally.. – AnswerDroid Nov 13 '15 at 07:49