简体   繁体   中英

app:dexDebug error in build.gradle Android Studio

I am receiving the app:dexDebug error when trying to run my project on Android Studio. 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'.

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

My dependencies in the build.gradle file are as follows:

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

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.

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. app:dexDebug error indicates you have exceeded the 65k method limit. 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. Eg to use Gcm, you only need to add compile 'com.google.android.gms:play-services-gcm:8.4.0'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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