Android - 任务'执行失败':app:dexDebug'

时间:2015-09-13 06:48:53

标签: android android-gradle

编译项目时遇到问题,我收到错误Execution failed for task ':app:dexDebug'。 错误:任务':app:dexDebug'执行失败。

  

com.android.ide.common.internal.LoggedErrorException:无法运行命令:       C:\ Users \ Diana \ AppData \ Local \ Android \ sdk \ build-tools \ 21.1.2 \ dx.bat --dex --no-optimize --output C:\ Users \ Diana \ Downloads \ VoiceTranslator \ app \ build \ intermediates \ dex \ debug --input-list = C:\ Users \ Diana \ Downloads \ VoiceTranslator \ app \ build \ intermediates \ tmp \ dex \ debug \ inputList.txt   错误代码:       2   输出:       意外的顶级例外情况:       com.android.dex.DexException:多个dex文件定义了Landroid / support / v4 / accessibilityservice / AccessibilityServiceInfoCompatIcs;           在com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)           在com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)           在com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)           在com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)           在com.android.dx.merge.DexMerger.merge(DexMerger.java:189)           在com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)           在com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)           在com.android.dx.command.dexer.Main.run(Main.java:246)           在com.android.dx.command.dexer.Main.main(Main.java:215)           在com.android.dx.command.Main.main(Main.java:106)

我知道这个问题已被多次询问,但我已经尝试过那里的解决方案,但在我的案例中没有一个可以解决。

这是我的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "imp.translator.diana.voicetranslator"
        minSdkVersion 9
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile files('libs/android-support-v4.jar', 'libs/microsoft-translator-java-api-0.6.1-jar-with-dependencies.jar')
}

任何想法在这里可能有什么问题?任何提示将不胜感激!

1 个答案:

答案 0 :(得分:1)

'libs/android-support-v4.jar'移除compile files(...)。此文件是appcompat-v7库的传递依赖项。