java - 错误 :Execution failed for task ':app:dexDebug' at runtime

标签 java android jvm runtime build.gradle

我遇到了这个运行时错误。它说:

错误:任务 ':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

这是我的 build.gradle 脚本:

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')

请帮助我。谢谢!

最佳答案

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

  1. 更改 Gradle 构建配置以启用 multidex
  2. 修改 list 以引用 MultiDexApplication 类

修改您的应用 Gradle 构建文件配置以包含支持库并启用 multidex 输出。

    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'
}

详情可以看我的回答DexIndexOverflowException Only When Running Tests

关于java - 错误 :Execution failed for task ':app:dexDebug' at runtime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33605002/

相关文章:

android - 在 float 操作按钮中创建菜单

java - 如何读取 +PrintTenuringDistribution 的输出

java - 如何处理java.lang.OutOfMemoryError : Java heap space error on Google App Engine?

java - 发生 OutOfMemoryError 时 Java 进程的行为

java - Android 应用程序返回 NaN

java - 无法使用 ServletFileUpload 上传 100MB 文件

java - 当我在浏览器中输入网址时,无法打开即时应用程序

java - 默认类名 - 代码味道?

android - 将 Zip 提取到 SD 卡非常慢。我如何优化性能?

java - android 新手问题 ArrayAdapter.setAdapter 上的空指针