Error:Execution failed for task ':app:dexDebug' error in my project while I added new dependency
Error:Execution failed for task ':app:dexDebug' error in my project while I added new dependency
我没有在我的项目中添加任何库/jar(在 libs 中)只有这个依赖项。
我的 build.gradle 文件。
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'
}
一旦我将这个“compile 'com.squareup.okhttp:okhttp:2.6.0'”添加到我的项目中,我就会得到这个
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
我 运行 我的项目时出现错误....
如果我删除这个“compile 'com.squareup.okhttp:okhttp:2.6.0'”依赖我的程序运行正常。
有时如果我添加了 Facebook 依赖项也会出现同样的错误...
首先您可以使用 compile 'com.squareup.okhttp:okhttp:2.5.0'
而不是您的。你可以看看我的回答
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
}
http://developer.android.com/intl/es/tools/building/multidex.html
添加
useLibrary 'org.apache.http.legacy'
在你的gradle之前的compileSdkversion...
您也可以将下面的代码与 IntelliJ Amiya 答案一起使用。
在某些情况下,这段代码对我有用
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
}
}
你可以通过申请class
public class MyApplication extends MultiDexApplication { .. }
或
override
attachBaseContext method and call MultiDex.install().
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
否则(如果您的应用程序没有自定义应用程序实现),请在 AndroidManifest.xml 中将 MultiDexApplication 声明为应用程序实现。
<application
android:name="android.support.multidex.MultiDexApplication"
.. >
..
</application>
我没有在我的项目中添加任何库/jar(在 libs 中)只有这个依赖项。
我的 build.gradle 文件。
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'
}
一旦我将这个“compile 'com.squareup.okhttp:okhttp:2.6.0'”添加到我的项目中,我就会得到这个
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
我 运行 我的项目时出现错误....
如果我删除这个“compile 'com.squareup.okhttp:okhttp:2.6.0'”依赖我的程序运行正常。
有时如果我添加了 Facebook 依赖项也会出现同样的错误...
首先您可以使用 compile 'com.squareup.okhttp:okhttp:2.5.0'
而不是您的。你可以看看我的回答
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
}
http://developer.android.com/intl/es/tools/building/multidex.html
添加
useLibrary 'org.apache.http.legacy'
在你的gradle之前的compileSdkversion...
您也可以将下面的代码与 IntelliJ Amiya 答案一起使用。 在某些情况下,这段代码对我有用
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
}
}
你可以通过申请class
public class MyApplication extends MultiDexApplication { .. }
或
override
attachBaseContext method and call MultiDex.install().
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
否则(如果您的应用程序没有自定义应用程序实现),请在 AndroidManifest.xml 中将 MultiDexApplication 声明为应用程序实现。
<application
android:name="android.support.multidex.MultiDexApplication"
.. >
..
</application>