顶级异常应用程序:dexDebug --dex -no-optimize --output android studio

时间:2015-01-09 07:25:03

标签: android eclipse android-studio dex

我正在将我的Android代码从Eclipse迁移到Android工作室,并且遇到了以下错误。该项目构建良好并与gradle同步,但它在编译时抛出以下错误。

UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':app:dexDebug'.
  

com.android.ide.common.internal.LoggedErrorException:无法运行命令:       /home/Work/adt-bundle-linux-x86-20130729/sdk/build-tools/21.1.2/dx --dex --no-optimize --output / home / Work / Roadblock / Android Studio Projects New / app / build / intermediates / dex / debug --input-list = / home / Work / Roadblock / Android Studio Projects New / app / build / intermediates / tmp / dex / debug / inputList.txt     错误代码:       2     输出:       意外的顶级例外情况:       com.android.dex.DexException:多个dex文件定义了Landroid / support / v4 / view / PagerAdapter;           在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)   信息:建筑失败   信息:总时间:22.183秒

我试图用jar和库解决这种错误,甚至尝试插入

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

当我在支持库中发生冲突时。但这与构建工具似乎是一种不同的错误。我试图检查输入listList.txt文件,如路径/ home / Work / Roadblock / Android Studio Projects New / app / build / intermediates / tmp / dex / debug / inputList.txt中提到的那样,但是没有找到任何相关内容,因为它是由系统。

我之前的问题(Android Studio not detecting support libraries on Compilation)提供了有关项目结构的详细信息,这似乎是从build.gradle中删除配置标记后的错误。我检查了所使用的每个文件和库,并删除了可能多次添加的jar,但是这个错误仍然存​​在。

依赖关系:

apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "package.app"
    minSdkVersion 8
    targetSdkVersion 18
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
    }
}

dependencies {
compile project(':facebookSDK')
compile project(':library')
compile project(':newPagerIndicator')
compile project(':pulltorefreshlib')
compile project(':volley')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
compile files('libs/FlurryAnalytics_3.3.3.jar')
compile files('libs/crittercism_v3_2_0_sdkonly.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/picasso-2.3.3.jar')
compile files('libs/universal-image-loader-1.8.4.jar')
}

1 个答案:

答案 0 :(得分:1)

Android build fails over com.android.dex.DexException: Multiple dex files define Landroid/support

exclude解决

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar', exclude: 'android-support-*.jar')
    //...
}

Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat exclude module: 'support-v4'

例如

dependencies {
    compile('com.commonsware.cwac:camera-v9:0.5.4') {
      exclude module: 'support-v4'
    }

    compile 'com.android.support:support-v4:18.0.+'
}

(也张贴到Gradle Exclude or add reference for JAR file hard included inside library classes.jar