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

标签 android eclipse android-studio dex

我正在将我的 Android 代码从 Eclipse 迁移到 Android studio,但一直卡在以下错误中。该项目构建良好并与 gradle 同步,但在编译时抛出以下错误。

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

com.android.ide.common.internal.LoggedErrorException: Failed to run command: /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 Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/view/PagerAdapter; 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) Information:BUILD FAILED Information:Total time: 22.183 secs

我已经尝试用 jars 和库来解决这种错误,甚至尝试插入

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

当我在支持库中遇到冲突时。但这似乎是构建工具的另一种错误。我尝试检查路径/home/Work/Roadblock/Android Studio Projects New/app/build/intermediates/tmp/dex/debug/inputList.txt 中提到的 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')
}

最佳答案

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

通过 exclude as 解决

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)

关于android - 顶级异常应用程序 :dexDebug --dex -no-optimize --output android studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27855722/

相关文章:

java - android:检测设备倾斜角度的主要问题

在 Eclipse IDE 上开发 Iphone 应用程序?

eclipse - Apache tomcat 7 本地主机页面没有错误,但是运行项目 : show HTTP Status 404 时

android - Alert.Dialog 生成器代码无法访问

java - 如何为 png 图像设置ColorFilter

android - 如何在具有预定义依赖项的 Build.gradle 中获取新版本警告?

android - MediaScannerConnection scanFile 扫描器崩溃

android - 如何在Android中默认打开一个 fragment ?如何签署被点击的按钮?

eclipse - 错误找不到工厂: javax. faces.context.FacesContextFactory

java - Firebase,类映射器 : no setter/field found for 'UserTwo' on class 'myclass'