android build-gradle错误:app:dexDebug

时间:2015-03-20 10:11:38

标签: android build.gradle

这是我的build.gradle文件(在app模块中):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.myFirtApp"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories { mavenCentral() }

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile 'com.google.android.gms:play-services:7.0.0'
}

我得到的错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]:    65536
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
at com.android.dx.command.Main.main(Main.java:106)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:283)

错误:任务':app:dexDebug'执行失败。

  

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令'C:\ Program Files \ Java \ jdk1.7.0_02 \ bin \ java.exe''已完成具有非零退出值2

还有其他人遇到过这个问题吗?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

问题解决了;其中一个jar文件是测试版,在使用两天后导致问题;一旦删除,该应用程序就可以正常运行。