Android Studio构建错误

时间:2014-03-28 19:00:23

标签: android

我一直在努力解决这个问题。我无法弄清楚该怎么做,当我想调试项目时,我会遇到以下输出错误。

Execution failed for task ':inspectoratecalculator:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\FlikFlak\AppData\Local\Android\android-studio\sdk\build-tools\android-4.4.2\dx.bat --dex --output 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\dex\debug
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\classes\debug 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\dependency-cache\debug 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\android-support-v4-9fdb020c999e0f186e4aef883e8a4b8676e1e3ac.jar 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\classes-3cbf09a1ad548c6398f541ca3aae99491954a4cd.jar 
C:\Users\FlikFlak\AndroidStudioProjects\Inspectorate\inspectoratecalculator\build\pre-dexed\debug\support-v4-19.1.0-ce3af6ab4e02f6c952693d6706242484504a4302.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)

-------------------------------------的build.gradle ---- -------------------------------

    apply plugin: 'android'

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'

}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

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

dependencies {
    compile 'com.android.support:appcompat-v7:+'

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

3 个答案:

答案 0 :(得分:1)

从@rupps提到的项目/模块jar目录中删除v4 JAR文件。同时从配置中删除“排除”部分。因为您正在使用appcompat-v7依赖项,所以您将通过Maven自动获取v4支持库。

答案 1 :(得分:0)

这可能是因为您在多次构建项目期间引用了相同的jar,可能是该jar已经包含在其他模块或库模块中。请检查并确保此条件不存在。

我们早些时候遇到过这种问题。

答案 2 :(得分:0)

我不确定你和我有同样的问题,但我的问题是我使用JDK 1.8编译代码,而android dx工具不支持。

此修复程序将项目的Module Settings中的SDK路径从1.8更改为1.7 JDK。

在Mac中引用此详细信息配置: https://stackoverflow.com/a/24680375/1043032