問題描述
我沒有在我的項(xiàng)目中(在 libs 中)添加任何庫/罐子,只有這個(gè)依賴項(xiàng).
我的 build.gradle 文件.
<代碼>android {compileSdkVersion 23構(gòu)建工具版本23.0.1"默認(rèn)配置 {應(yīng)用程序IDcom.android.example23"minSdkVersion 14targetSdkVersion 23版本代碼 1版本名稱1.0"}構(gòu)建類型 {發(fā)布 {縮小啟用假proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}}}依賴{編譯文件樹(包括:['*.jar'],目錄:'libs')測試編譯'junit:junit:4.12'編譯'com.android.support:appcompat-v7:23.1.1'編譯'com.android.support:cardview-v7:23.1.1'編譯'com.android.support:recyclerview-v7:23.1.1'編譯'com.android.support:support-v4:23.1.1'編譯 'com.melnykov:floatingactionbutton:1.1.0'編譯'com.android.support:design:23.1.1'編譯'org.apache.directory.studio:org.apache.commons.io:2.4'編譯'com.google.android.gms:play-services:8.3.0'編譯'com.squareup.picasso:picasso:2.5.2'編譯'com.parse:parse-android:1.11.0'編譯'com.naver.android.helloyako:imagecropview:1.0.3'編譯'com.squareup.okhttp:okhttp:2.6.0'}
一旦我將這個(gè)compile 'com.squareup.okhttp:okhttp:2.6.0'"添加到我的項(xiàng)目中,我就會得到這個(gè)
錯(cuò)誤:任務(wù) ':app:dexDebug' 執(zhí)行失敗.
<塊引用>
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:Program FilesJavajdk1.8.0_45injava.exe'' 完成非零退出值 2
運(yùn)行項(xiàng)目時(shí)出現(xiàn)錯(cuò)誤....
如果我刪除這個(gè)compile 'com.squareup.okhttp:okhttp:2.6.0'"依賴,我的程序就可以正常工作了.
有時(shí)如果我添加了 Facebook 依賴項(xiàng),也會出現(xiàn)同樣的錯(cuò)誤......
你也可以使用下面的代碼和 IntelliJ Amiya 答案.在某些情況下,這段代碼對我有用
dexOptions {增量真javaMaxHeapSize "4g"}安卓 {compileSdkVersion 23構(gòu)建工具版本23.0.1"默認(rèn)配置 {minSdkVersion 14//低于14不支持multidextargetSdkVersion 22//啟用多索引支持.multiDexEnabled 真}}
你可以通過創(chuàng)建一個(gè)應(yīng)用程序類來做到這一點(diǎn)
public class MyApplication extends MultiDexApplication { .. }
或
覆蓋attachBaseContext 方法并調(diào)用 MultiDex.install().受保護(hù)的無效 attachBaseContext(上下文基礎(chǔ)){super.attachBaseContext(base);MultiDex.install(this);}
否則(如果您的應(yīng)用程序沒有自定義應(yīng)用程序?qū)崿F(xiàn)),請?jiān)谀?AndroidManifest.xml 中將 MultiDexApplication 聲明為應(yīng)用程序?qū)崿F(xiàn).
I didn't added any libraries / jars in my project( in libs ) only this dependencies.
My build.gradle file.
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.android.example23"
minSdkVersion 14
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.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.melnykov:floatingactionbutton:1.1.0'
compile 'com.android.support:design:23.1.1'
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.parse:parse-android:1.11.0'
compile 'com.naver.android.helloyako:imagecropview:1.0.3'
compile 'com.squareup.okhttp:okhttp:2.6.0'
}
Once I am adding this " compile 'com.squareup.okhttp:okhttp:2.6.0' " into my project I am getting this
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:Program FilesJavajdk1.8.0_45injava.exe'' finished with non-zero exit value 2
Error is coming while I run my project....
If I remove this " compile 'com.squareup.okhttp:okhttp:2.6.0' " dependency my program is working fine.
Sometimes if I added Facebook dependency also the same error is coming...
you can use below code also with IntelliJ Amiya answer. In some case this code work for me
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
}
you can do by make an Application class
public class MyApplication extends MultiDexApplication { .. }
or
override
attachBaseContext method and call MultiDex.install().
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Otherwise (if your application does not have custom Application implementation), declare MultiDexApplication as application implementation in your AndroidManifest.xml.
<application
android:name="android.support.multidex.MultiDexApplication"
.. >
..
</application>
這篇關(guān)于錯(cuò)誤:在我添加新依賴項(xiàng)時(shí),我的項(xiàng)目中的任務(wù) ':app:dexDebug' 錯(cuò)誤執(zhí)行失敗的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!