简体   繁体   English

Android Studio错误,多个dex文件

[英]Android Studio error, multiple dex files

I am unable to build my project, it is returning me one error. 我无法建立我的专案,却传回我一个错误。 There are no errors in the files themselves, only upon a build. 文件本身没有错误,仅在构建时。

This is the following error: 这是以下错误:

Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\Jay\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Users\Jay\Desktop\UploadToServer\app\build\intermediates\dex\debug --input-list=C:\Users\Jay\Desktop\UploadToServer\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
        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)

I have read on a few other post that it could be multiples of the same jar files in the libs folder but currently my folder is empty, I am not to sure what the issue is, I would appreciate if someone could help. 我在其他几篇文章中读到,它可能是libs文件夹中相同jar文件的倍数,但目前我的文件夹为空,我不确定是什么问题,如果有人可以提供帮助,我将不胜感激。

Here is my module build.gradle 这是我的模块build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.jay.uploadtoserver"
        minSdkVersion 16
        targetSdkVersion 21
        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:21.0.3'
    compile 'com.google.android.gms:play-services:+'
    compile 'com.google.android:support-v4:r6'
    compile 'org.apache.httpcomponents:httpmime:4.2.3'

}

Some of your jar files does not compile. 您的某些jar文件无法编译。 You should go into your build.gradle file in your project, and look in your dependencies, if your just import some jar files, you could try to remove them, and add one at a time, to see which one of them makes the error. 您应该进入项目中的build.gradle文件,并查看您的依赖项,如果您只是导入了一些jar文件,则可以尝试将其删除,然后一次添加一个,以查看其中哪个错误。

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:+'
compile 'com.google.android:support-v4:18.0.+'
}

Remove compile 'com.google.android:support-v4:r6 '. 删除compile 'com.google.android:support-v4:r6 ”。 AppCompat already has this library AppCompat已拥有此库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM