多个dex文件定义Landroid/support/v4 /

Kam*_*icz 2 android gradle android-manifest android-support-library android-studio

我无法编译项目得到以下错误编译:

错误:任务':myApp:dexDebug'的执行失败.

com.android.ide.common.internal.LoggedErrorException:无法运行命令:C:\ Program Files文件(x86)的\ Android的\ Android的工作室\ SDK \构建工具\ 21.0.2\dx.bat --dex - 输出C:\用户\ Android Studio中\ Android Studio中\对myApp \建立\中间体\ DEX \调试--input列表= C:\ Users \用户对myApp \下载\ Android Studio中\ Android Studio中\对myApp \建立\中间体\ TMP\DEX \调试\ libraryList.txt错误代码:2输出:意外的顶级例外:com.android.dex.DexException:多DEX文件定义Landroid /支持/ V4/accessibilityservice/AccessibilityServiceInfoCompat $ AccessibilityServiceInfoVersionImpl; 在com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)

当然,这段代码解决了我的问题

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

但不幸的是不满足我

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')

    compile 'com.android.support:support-v4:21.+'
    compile project(':PullToRefreshListFragment')
    compile project(':validator')
    compile project(':AndroidBootstrap')

    compile 'com.google.android.gms:play-services:6.+'
    compile 'com.android.support:appcompat-v7:21+'

    compile 'com.github.codechimp-org.apprater:library:1.0.+'
    compile 'com.sothree.slidinguppanel:library:+'
    compile 'me.grantland:autofittextview:0.2.+'
    compile 'io.realm:realm-android:0.71.0'

    compile ('com.loopj.android:android-async-http:1.4.6')
    {
        exclude group: 'com.google.android', module: 'support-v4'
    }

    compile('de.keyboardsurfer.android.widget:crouton:1.8.5@aar') {
        exclude group: 'com.google.android', module: 'support-v4'
    }

    compile ('io.nlopez.smartlocation:library:2.+')
    {
        exclude(group: 'com.google.android', module: 'gms:play-services')
    }
    configurations {
      // all*.exclude group: 'com.android.support', module: 'support-v4'

    }
Run Code Online (Sandbox Code Playgroud)

我该如何编译项目?

use*_*330 6

这似乎是Android studio迁移问题的常见ADT.ADT正在libs/dir中寻找android-support-v4.jar的副本,而Android studio拥有它自己的内部副本.迁移jar文件时会留在libs目录中,这会创建一个重复的jar,很可能是旧版本.我删除了libs目录中的jar,问题解决了.