可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
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
回答1:
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.+'
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
回答2:
Add this to your file build. gradle
defaultConfig {
multiDexEnabled true
}
回答3:
The Android plugin for Gradle available in Android SDK Build Tools 21.1 and higher supports multidex, so you have to add multiDexEnabled true
to your gradle file like below :
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'
}
回答4:
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
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.
回答5:
I ran into the same problem and I did add the multiDexEnabled true
in build file but all in vain. But doing the following along with adding multiDexEnabled true
in defaultConfig solved my problem.
Add the MultiDexApplication in your manifest like :
<?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
回答6:
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
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')
then I fixed it to be like this
compile fileTree(include: ['*.jar'], dir: 'libs')
remove other setting import lib
I hope this helps
回答7:
This Problem can easily be resolved by Removing multiple jar in your project libs folder.