任务执行失败':app:dexDebug'在Android Studio上

时间:2015-04-16 10:22:56

标签: android android-studio build.gradle

我根本没有修改库依赖项甚至build.gradle脚本,只是修改了一些代码,但是这个错误突然出现,但之前没有。

>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_15\bin\java.exe'' finished with non-zero exit value 2

我尝试使用--stacktrace --debug,但不太明白我所看到的内容,似乎错误突然就像突然出现一样

>Merged dex A (3701 defs/5082.9KiB) with dex B (266 defs/275.0KiB). Result is 3967 defs/5328.6KiB. Took 1.3s
Result compacted from 10118.4KiB to 8222.8KiB to save 1895.6KiB
Merged dex A (3967 defs/5328.6KiB) with dex B (3293 defs/2941.1KiB). Result is 7260 defs/8222.8KiB. Took 1.6s

>AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}

现在,有什么可能是错的,或者我该怎么做才能理解出了什么问题?

这是我的gradle脚本,供参考

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.xxx.yyy"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 24
        versionName "2.1.2"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        javaMaxHeapSize "2g"
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.android.gms:play-services:6.1.71'
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile 'net.simonvt.menudrawer:menudrawer:3.0.+@aar'
    compile 'com.commonsware.cwac:sacklist:1.0.0'
    compile 'com.commonsware.cwac:merge:1.1.+'
    compile 'com.loopj.android:android-async-http:1.4.5'
    compile project(':library')
}

1 个答案:

答案 0 :(得分:2)

我设法通过在我的gradle脚本中的multiDexEnabled true部分下添加defaultConfig来解决此问题,但不知道为什么会这样。

<强>更新

这是由于65K的限制,正如@ clemp6r在评论中所解释的那样。