意想不到的顶级水平异常[Android Studio]

时间:2014-06-12 11:36:14

标签: android android-gradle viewpagerindicator

我在项目中添加了ViewPagerIndicator库。但是坚持这个问题:

以下是问题的日志

        Error:Execution failed for task ':pay:dexDebug'.
     com.android.ide.common.internal.LoggedErrorException: Failed to run command:
        /Documents/sdk/build-tools/19.1.0/dx --dex --num-threads=4 --output 
../build/intermediates/dex/debug 
../build/intermediates/classes/debug 
../build/intermediates/dependency-cache/debug 
../build/intermediates/pre-dexed/debug/butterknife-4.0.1-f7e234af31748238bde435dc44314700fd06e850.jar 
../build/intermediates/pre-dexed/debug/classes-8fe1b2ffe2359cd86de26b16b85db4b41a42d220.jar 
../build/intermediates/pre-dexed/debug/classes-f581d0cc66f4aeea4b71b96196fc37f7519c197a.jar 
../build/intermediates/pre-dexed/debug/library-2.4.1-9b63b9ebec4cf7cad28ee4701dc08c2d6b0ee55d.jar 
../build/intermediates/pre-dexed/debug/support-v4-19.1.0-e23f6fd20435425326ace2bf395d0471ff3c0c91.jar 
../build/intermediates/pre-dexed/debug/support-v4-r7-6ea93b73eed4a89fbd04d757993df085d37a4142.jar
      Error Code:
        2
      Output:
        UNEXPECTED TOP-LEVEL EXCEPTION:
        com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
            at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
            at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
            at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
            at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
            at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
            at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
            at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
            at com.android.dx.command.dexer.Main.run(Main.java:230)
            at com.android.dx.command.dexer.Main.main(Main.java:199)
            at com.android.dx.command.Main.main(Main.java:103)

这是我项目的构建文件:

    android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'
    defaultConfig {
        applicationId 'com.android.temp'
        minSdkVersion 10
        targetSdkVersion 19
        versionCode 1
        versionName '1.0'
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.viewpagerindicator:library:2.4.1'
    compile 'com.jakewharton:butterknife:4.0.+'
    compile project(':view_pager_indicator')
    compile 'com.android.support:support-v4:+'
    compile 'com.android.support:appcompat-v7:+'
}

以下是图书馆项目的构建文件:

    android {
    compileSdkVersion 19
    buildToolsVersion "19.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 16
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}


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

请帮助我,我错了。 我已经搜索并尝试了SO上提供的其他解决方案,但它们都没有为我工作。

1 个答案:

答案 0 :(得分:1)

发现我的错误:

我为同一个库项目添加了两个依赖项即。 ViewPagerIndicator

compile 'com.viewpagerindicator:library:2.4.1'
..

compile 'com.android.support:support-v4:+'

删除其中一个解决了我的问题。