简体   繁体   English

app:dexDebug在build.gradle Android Studio中出错

[英]app:dexDebug error in build.gradle Android Studio

I am receiving the app:dexDebug error when trying to run my project on Android Studio. 尝试在Android Studio上运行项目时,我收到app:dexDebug错误。 I believe it's got to do with my dependencies but I am not sure where I am going wrong. 我相信这与我的依赖关系有关,但我不确定我要去哪里。

The error is: 错误是:

Error:Execution failed for task ':app:dexDebug'. 错误:任务':app:dexDebug'的执行失败。

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\\Program Files\\Java\\jdk1.7.0_17\\bin\\java.exe'' finished with non-zero exit value 2 com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\\ Program Files \\ Java \\ jdk1.7.0_17 \\ bin \\ java.exe'以非零退出值2

My dependencies in the build.gradle file are as follows: 我对build.gradle文件的依赖关系如下:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
}

Can anyone point me in the correct direction here, please. 任何人都可以在这里指出正确的方向。

Thank you. 谢谢。

UPDATE 更新

Problem solved by adding the following to my build.gradle 通过将以下内容添加到我的build.gradle中来解决问题

packagingOptions {
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/NOTICE'
    }

Android Studio Error:Execution failed for task ':app:dexDebug' to solve it setting multiDexEnabled to true in your gradle file. Android Studio中Error:Execution failed for task ':app:dexDebug'来解决它设置multiDexEnabledtrue在你的文件的gradle。

defaultConfig {        
    // Enabling multidex support.
    multiDexEnabled true
}

The problem is most likely caused by adding all play services dependencies. 该问题很可能是由于添加了所有播放服务依赖项引起的。 You should not compile the entire package of APIs into your app, it increases the number of methods in your app. 您不应该将整个API包编译到您的应用中,否则会增加应用中方法的数量。 app:dexDebug error indicates you have exceeded the 65k method limit. app:dexDebug错误指示您已超过65k方法限制。 Remove this line in your build.gradle: compile 'com.google.android.gms:play-services:8.3.0' then choose from these seperate dependencies , the ones to add based on what your app needs. 在build.gradle中删除此行: compile 'com.google.android.gms:play-services:8.3.0'然后从这些单独的依赖项中进行选择,这些依赖项将根据您的应用程序的需要进行添加。 Eg to use Gcm, you only need to add compile 'com.google.android.gms:play-services-gcm:8.4.0' 例如,要使用Gcm,您只需添加compile 'com.google.android.gms:play-services-gcm:8.4.0'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM