简体   繁体   中英

Error:Execution failed for task ':app:dexDebug' at runtime

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!

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

defaultConfig {
     multiDexEnabled true 
}

Add multiDexEnabled true inside your defaultConfig in your build.gradle.
Hope that will work for 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