错误:在我的项目错误,我增加了新的依赖执行失败的任务“:dexDebug:应用” [英] Error:Execution failed for task ':app:dexDebug' error in my project while I added new dependency
问题描述
我不添加任何库/在我的项目罐子(在库)只有这个相关性。
我的build.gradle文件。
安卓{
compileSdkVersion 23
buildToolsVersion23.0.1defaultConfig {
的applicationIDcom.android.example23
14的minSdkVersion
targetSdkVersion 23
版本code 1
的versionName1.0
}
buildTypes {
发布 {
minifyEnabled假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
}
}
}依赖{
编译文件树(包括:['的* .jar'],DIR:库)
testCompile'的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:播放服务:8.3.0
编译com.squareup.picasso:毕加索:2.5.2
编译com.parse:语法分析的android:1.11.0
编译com.naver.android.helloyako:imagecropview:1.0.3
编译com.squareup.okhttp:okhttp:2.6.0
}
在我加入这个编译com.squareup.okhttp:okhttp:2.6.0到我的项目,我得到这个
错误:执行失败的任务:应用程序:dexDebug。
com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:过程'命令'C:\\ Program Files文件\\的Java \\ jdk1.8.0_45 \\斌\\ java.exe的'完成非零退出值2
块引用>而我跑我的项目错误来了....
如果我删除这个编译com.squareup.okhttp:okhttp:2.6.0。'依赖我的程序工作正常。
有时候,如果我加入Facebook的依赖也同样的错误来了......
解决方案您可以在下面code也与使用的的IntelliJ阿米亚·的答案。
在某些情况下,这code为我工作dexOptions {
真正的增量
javaMaxHeapSize4G
}安卓{
compileSdkVersion 23
buildToolsVersion23.0.1 defaultConfig {
14的minSdkVersion //超过14下不支持multidex
targetSdkVersion 22 //启用multidex支持。
multiDexEnabled真
}
}您可以通过做使应用程序类
公共类MyApplication的扩展MultiDexApplication {..}
或
覆盖
attachBaseContext方法和调用MultiDex.install()。
保护无效attachBaseContext(上下文基地){
super.attachBaseContext(基峰);
MultiDex.install(本);
}否则(如果您的应用程序不具有自定义应用程序实现),声明MultiDexApplication在AndroidManifest.xml中的应用实施。
<应用
机器人:名字=android.support.multidex.MultiDexApplication
..>
..
< /用途>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 Files\Java\jdk1.8.0_45\bin\java.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>
这篇关于错误:在我的项目错误,我增加了新的依赖执行失败的任务“:dexDebug:应用”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!