任务":app:dexDebug"的执行失败。com.android.ide.common.process.ProcessException: org.gradle.process.internal.



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

错误:任务":app:dexDebug"的执行失败。>com.android.ide.common.prrocess.ProcessException:org.gradle.prrocess.internal.ExecException:进程"command"/usr/lib/jvm/java-7-openjdk-amd64/bin/java"以非零退出值2 结束

将其添加到文件构建中。渐变

defaultConfig {
     multiDexEnabled true 
}

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

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

错误:任务":app:dexDebug"的执行失败。>com.android.ide.common.prrocess.ProcessException:org.gradle.prrocess.internal.ExecException:进程"command"/usr/lib/jvm/java-7-openjdk-amd64/bin/java"以非零退出值2 结束

IntelliJ编译方式可能会导致您发布的错误(至少在我的情况下是这样)。我最近来自Eclipse,在那里每次运行后都会生成一个"Clean Project"。在IntelliJ中,项目需要一个干净的生成才能运行。我避免了每次都进行清理,在build.gradle.

的dexOptions中禁用增量标志

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

在清单中添加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>

别忘了添加

defaultConfig {
     multiDexEnabled true 
}

为我做了这个把戏。参考:Android Studio未能调试,错误为org.gradle.process.internal.ExecException

我也遇到了同样的错误。但是,我通过在依赖项中添加build.gradle中缺少的行来解决这个问题。编译com.parse.bolts:boltsandroid: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")  }

你也可以与你的匹配,看看它是否也能帮助你。

与我的错误相同

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

这是因为它的依赖库有重复,在我的例子中,比如这个

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

然后我把它改成这样compile fileTree(include: ['*.jar'], dir: 'libs')删除其他设置导入库

我希望这能帮助

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

相关内容

最新更新