任务':app:dexDebug'的执行失败。 65K方法限制

时间:2016-02-02 22:58:15

标签: android android-gradle

当我尝试构建应用程序时,我得到了这个。这与65k方法限制有关吗?我已经在默认配置下输入了multiDexEnabled,并在依赖项下编译'com.android.support:multidex:1.0.0'?

AGPBI: {"kind":"simple","text":"UNEXPECTED TOP-LEVEL ERROR:","sources":[{}]}
AGPBI: {"kind":"simple","text":"java.lang.OutOfMemoryError: Java heap space","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.ssa.SsaBasicBlock.\u003cinit\u003e(SsaBasicBlock.java:124)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.ssa.SsaBasicBlock.newFromRop(SsaBasicBlock.java:147)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.ssa.SsaMethod.convertRopToSsaBlocks(SsaMethod.java:173)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.ssa.SsaMethod.newFromRopMethod(SsaMethod.java:103)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:44)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:98)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:297)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:137)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:93)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.processClass(Main.java:729)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.access$300(Main.java:83)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.processOne(Main.java:632)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.processAllFiles(Main.java:505)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.runMultiDex(Main.java:334)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:244)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.Main.main(Main.java:106)","sources":[{}]}

FAILURE: Build failed with an exception.

* What went wrong:
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_65\bin\java.exe'' finished with non-zero exit value 3

的build.gradle

apply plugin: 'com.android.application'
apply plugin: 'android'

artifacts.add("default", file('gson-2.3.1.jar'))

dependencies {
    compile files('libs/gson-1.6.jar')
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.squareup:android-times-square:1.5.0@aar'
    compile 'com.google.code.gson:gson:1.6'
    compile 'com.github.alamkanak:android-week-view:1.2.1'
    compile files('libs/aniqroid.jar')
    compile files('libs/joda-time-2.8.2.jar')
    compile project(':fileChooser')
    compile 'com.github.PhilJay:MPAndroidChart:v2.0.9'
    compile 'com.github.citux:datetimepicker:0.1.2'
    compile 'com.github.gcacace:signature-pad:1.0.1'
    compile files('src/main/resources/commons-io-2.4.jar')
    compile files('src/main/resources/commons-io-2.4-javadoc.jar')
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    compile files('libs/jackson-core-2.5.0.jar')
    compile 'com.facebook.stetho:stetho:1.3.0'
    compile 'com.facebook.stetho:stetho-okhttp3:1.3.0'
    compile 'com.facebook.stetho:stetho-js-rhino:1.3.0'
    compile 'com.android.support:multidex:1.0.0'
}
android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "cimsmobile.lexcom.com"
        minSdkVersion 14
        targetSdkVersion 21
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}
repositories {
    maven { url "https://jitpack.io" }
}

android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
}

1 个答案:

答案 0 :(得分:1)

Google Play服务非常庞大,您可能不需要其中的所有API 你应该只编译你需要的Google Play服务,而不是使用

multiDexEnabled true

这可能导致编译问题,除非你绝对需要它,但是大多数人倾向于只启用它而不会找到问题的根源。

请在android studio的终端导航到项目的根目录并执行:

 ./gradlew app:dependencies

这将列出您在应用中编译的所有依赖项,考虑到您所依赖的库数量,您可能会有多个重复项。

Google Play服务列表位于{strong> 选择性地将API编译为可执行文件