意想不到的顶级EXCEPTION安卓工作室

时间:2014-12-04 08:50:43

标签: android android-studio android-gradle build.gradle

我正在开发一个android工作室项目,一切都很好,直到我添加    编译' com.android.support:recyclerview-v7:+' build.gradle文件。我一直在寻找2天的解决方案,但尚未找到。

Information:Gradle tasks [:app:assembleDebug] :app:preBuild :app:compileDebugNdk UP-TO-DATE
:app:preDebugBuild 
:app:checkDebugManifest 
:app:preReleaseBuild 
:app:prepareComAndroidSupportAppcompatV72100Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72102Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42102Library UP-TO-DATE
:app:prepareComGithubMrengineer13Snackbar040Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices6171Library UP-TO-DATE
:app:prepareDebugDependencies 
:app:compileDebugAidl UP-TO-DATE 
:app:compileDebugRenderscript UP-TO-DATE 
:app:generateDebugBuildConfig UP-TO-DATE 
:app:generateDebugAssets UP-TO-DATE 
:app:mergeDebugAssets UP-TO-DATE 
:app:generateDebugResValues UP-TO-DATE 
:app:generateDebugResources UP-TO-DATE 
:app:mergeDebugResources UP-TO-DATE 
:app:processDebugManifest UP-TO-DATE 
:app:processDebugResources UP-TO-DATE 
:app:generateDebugSources UP-TO-DATE 
:app:compileDebugJava 
:app:preDexDebug 
:app:dexDebug 
UNEXPECTED TOP-LEVEL EXCEPTION: 
Error:Execution failed for task ':app:dexDebug'.

> com.android.ide.common.internal.LoggedErrorException: Failed to run command:      /Users/mobven/Desktop/Android SDK/sdk/build-tools/21.1.0/dx --dex --output /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/dex/debug /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/classes/debug /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/dependency-cache/debug /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/android-support-4.0-96f0e9cf7990afcb0b54c3d327a3aced85a5af15.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/classes-20f85e113689efd0f4d808bbf1312e09c43bdc49.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/classes-440f6b09f10e8e30a1118a4d2d43be583bad0959.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/classes-5a02f8ebc8798b4c3710b33fb2c074683173cb80.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/classes-6989a5d493505095675afd12d6931b51cf429992.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/classes-a6edf6fa0c3d2cb2cec1edb40923a7d765d78fb0.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/gson-2.3-7dd4601f2faeb82b5beefe363da658c9ae925581.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/internal_impl-21.0.2-1aafd0446915d1011bb9668a6ac8f1defcf9191b.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/parceler-0.2.13-68a2a9c6331b436a4224a892389405276283d547.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/parceler-api-0.2.13-1072eb832cf4d87fb253f15aa798d90ebce68715.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/picasso-2.4.0-f12467e4b369fb01d4a49695801fd3e502b511b8.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/retrofit-1.6.1-3e3f707b537476742224240911665405915f3e6d.jar /Users/mobven/Desktop/HesapAlMaterial/app/build/intermediates/pre-dexed/debug/support-annotations-21.0.2-8c0b808a6eea01eb2d7e9f3bb66927cb2d265768.jar Error Code:    2   Output:     UNEXPECTED TOP-LEVEL EXCEPTION:     com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/BackStackRecord$Op;
        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:302)
        at com.android.dx.command.dexer.Main.run(Main.java:245)
        at com.android.dx.command.dexer.Main.main(Main.java:214)
        at com.android.dx.command.Main.main(Main.java:106)

这是build.grade文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "com.mobven.hesapal"
        minSdkVersion 9
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    } }

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.google.android.gms:play-services:6.1.71'
    compile 'com.github.mrengineer13:snackbar:0.4.0'
    compile 'com.squareup.retrofit:retrofit:1.6.1'
    compile 'com.google.code.gson:gson:2.3'
    compile 'org.parceler:parceler:0.2.13'
    compile files('libs/picasso-2.1.1.jar') }

提前完成

2 个答案:

答案 0 :(得分:1)

找到解决方案

我删除了

compile 'org.parceler:parceler:0.2.13'

它开始工作。我认为parceled lib也指支持V4但我不确定为什么它开始工作或为什么它不使用parceled lib.Anyway我发布解决方案,如果有人有同样的问题。< / p>

答案 1 :(得分:0)

请再次检查libs文件夹,您在`dependencies'的第一行将包含该文件夹中的所有jar。也许你当前的依赖列表中仍然存在一个库。

 compile fileTree(dir: 'libs', include: ['*.jar'])