简体   繁体   中英

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.

Here is my module 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. 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.

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 '. AppCompat already has this library

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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