Android"意想不到的顶级例外"

时间:2015-03-24 15:17:13

标签: android android-studio

出于某种原因,我的项目停止了工作。当我尝试运行它时,我收到以下错误:

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\LENOVO\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --output C:\Users\LENOVO\Projects\Stock.comLiveV2\b18-v12-1903\app\build\intermediates\dex\debug --input-list=C:\Users\LENOVO\Projects\appy\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lbolts/AggregateException;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
        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.command.dexer.Main.run(Main.java:246)
        at com.android.dx.command.dexer.Main.main(Main.java:215)
        at com.android.dx.command.Main.main(Main.java:106)

昨天项目很好,我没有改变任何意义。 我的gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.stock.app"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 4
        versionName "1.0.4"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'


    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile 'com.google.android.gms:play-services:6.1.+'

    compile files('libs/gson-1.7.jar')


    compile ('oauth.signpost:signpost-commonshttp4:1.2.1.2') {
        exclude module: 'commons-logging'
        exclude module: 'httpcore'
        exclude module: 'httpclient'
    }
    compile ('oauth.signpost:signpost-core:1.2.1.2') {
        exclude module: 'commons-codec'
    }


    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')


    compile 'com.mcxiaoke.volley:library:1.0.+'
}

我该怎么办?在寻找解决方案之后,找到一个可以替换它的解决方案:

classpath 'com.android.tools.build:gradle:1.0.1'

用这个:

classpath 'com.android.tools.build:gradle:1.1.2'

但它不起作用。

更新:我尝试删除解析螺栓,但同样的错误eccours。我目前的傻瓜:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'


    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile 'com.google.android.gms:play-services:6.1.+'

    compile files('libs/gson-1.7.jar')


    compile ('oauth.signpost:signpost-commonshttp4:1.2.1.2') {
        exclude module: 'commons-logging'
        exclude module: 'httpcore'
        exclude module: 'httpclient'
    }
    compile ('oauth.signpost:signpost-core:1.2.1.2') {
        exclude module: 'commons-codec'
    }


    compile fileTree(dir: 'libs', include: 'Parse-*.jar')


    compile 'com.mcxiaoke.volley:library:1.0.+'
}

编辑:事实证明,问题在于我有3个螺栓:一个来自Facebook,一个来自Parse.com,另一个来自app-compact。我不得不删除其中的两个。

到目前为止,我仍然不明白该项目是如何运作的 - 至于我从第1天开始使用所有这些库。

2 个答案:

答案 0 :(得分:0)

问题出现是因为您尝试两次包装相同的人工制品。正如您可以从" facebook-android-sdk"中看到here POM文件,这个库已经打包了#34; bolt-android"。因此,只需从构建文件中删除此依赖项,它应该可以工作:

compile 'com.parse.bolts:bolts-android:1.+'

答案 1 :(得分:0)

Facebook SDK和appcompact库附带了lbolts-android库,可能导致版本不匹配,从而导致DexException。

检查this问题。

查看项目中包含的私有库,特别是如果有多个lbolts实例。