Java 任务“:app:dexDebug”执行失败。com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29460443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 08:03:25  来源:igfitidea点击:

Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException

javaandroiddocx4j

提问by Wahib

I am building my android project when i got this error after import docx4j library in my project. What should i do to get rid of this exception.

在我的项目中导入 docx4j 库后出现此错误时,我正在构建我的 android 项目。我应该怎么做才能摆脱这个异常。

Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2

错误:任务 ':app:dexDebug' 执行失败。> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' 以非完成- 零退出值 2

采纳答案by Karan Khara

I had got the same error. But I resolved the issue by adding the following missing line from build.gradle in dependencies. compile 'com.parse.bolts:bolts-android:1.+'

我遇到了同样的错误。但是我通过在依赖项中从 build.gradle 添加以下缺失的行来解决这个问题。编译'com.parse.bolts:bolts-android:1.+'

After adding this line, my dependencies body was like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile fileTree(dir: 'libs', include: "commons-io-2.4.jar")  }

You can match with yours too and see if it can help you too

你也可以搭配你的,看看它是否也能帮助你

回答by TomaTo

I might need more information but according to the error on your question:

我可能需要更多信息,但根据您问题中的错误:

Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2

错误:任务 ':app:dexDebug' 执行失败。> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' 以非完成- 零退出值 2

The IntelliJ compilation way might cause the error you post (at least in my case, it does). I recently came from Eclipse, where a 'Clean Project' is made after every run. In IntelliJ, the project needs a clean build to be run. I've avoided cleaning every time, disabling incremental flag inside dexOptions of the build.gradle.

IntelliJ 编译方式可能会导致您发布错误(至少在我的情况下是这样)。我最近来自 Eclipse,每次运行后都会创建一个“干净的项目”。在 IntelliJ 中,项目需要一个干净的构建才能运行。我每次都避免清理,禁用 build.gradle 的 dexOptions 内的增量标志。

回答by souttab

the same as my error

和我的错误一样

Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2enter code here

Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 2enter code here

it is because there is a duplication of its dependency lib, in my case like this

这是因为它的依赖库存在重复,在我的情况下是这样的

compile files('libs/httpcore-4.3.3.jar') compile files('libs/httpmime-4.3.6.jar') compile fileTree(include: ['*.jar'], dir: 'libs')

compile files('libs/httpcore-4.3.3.jar') compile files('libs/httpmime-4.3.6.jar') compile fileTree(include: ['*.jar'], dir: 'libs')

then I fixed it to be like this compile fileTree(include: ['*.jar'], dir: 'libs')remove other setting import lib

然后我将其修复为这样 compile fileTree(include: ['*.jar'], dir: 'libs')删除其他设置导入库

I hope this helps

我希望这有帮助

回答by souttab

Add this to your file build. gradle

将此添加到您的文件构建中。等级

defaultConfig {
     multiDexEnabled true 
}

回答by serabile

The Android plugin for Gradle available in Android SDK Build Tools 21.1 and higher supports multidex, so you have to add multiDexEnabled trueto your gradle file like below :

Android SDK Build Tools 21.1 及更高版本中提供的适用于 Gradle 的 Android 插件支持 multidex,因此您必须添加multiDexEnabled true到您的 gradle 文件中,如下所示:

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

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

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

回答by San

I ran into the same problem and I did add the multiDexEnabled truein build file but all in vain. But doing the following along with adding multiDexEnabled truein defaultConfig solved my problem.

我遇到了同样的问题,我确实添加了multiDexEnabled true构建文件,但都是徒劳的。但是执行以下操作并添加multiDexEnabled truedefaultConfig 解决了我的问题。

Add the MultiDexApplication in your manifest like :

在您的清单中添加 MultiDexApplication,如:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

And dont forget to add

并且不要忘记添加

defaultConfig {
     multiDexEnabled true 
}

The did the trick for me. Ref : Android Studio fails to debug with error org.gradle.process.internal.ExecException

这对我有用。参考:Android Studio 调试失败,错误为 org.gradle.process.internal.ExecException

回答by mehmoodnisar125

This Problem can easily be resolved by Removing multiple jar in your project libs folder.

通过删除项目 libs 文件夹中的多个 jar,可以轻松解决此问题。