顶级异常应用程序:dexDebug --dex -no-optimize --output android studio [英] Top-Level Exception app:dexDebug --dex -no-optimize --output android studio

查看:139
本文介绍了顶级异常应用程序:dexDebug --dex -no-optimize --output android studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的Android代码从Eclipse迁移到Android studio,并被困在以下错误之中。该项目构建良好,并与gradle进行同步,但在编译时会引起以下错误。

 未指定的顶级例外:
错误:执行失败的任务':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)
信息:BUILD FAILED
信息:总时间:22.183秒


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



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

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



我早期的问题( Android Studio没有检测到编译时的支持库)提供了有关项目结构的详细信息,这似乎是从build.gradle中删除配置标记后的错误。我检查了使用的每个文件和库,并删除了可能已添加多次的jar,但是这个错误仍然存​​在。



依赖关系:

 应用插件:'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion 21.1.2

defaultConfig {
applicationIdpackage.app
minSdkVersion 8
targetSdkVersion 18
}

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


依赖关系{
编译项目(':facebookSDK')
编译项目(':library')
编译项目(':newPagerIndicator')
编译项目(':pulltorefreshlib')
编译项目(':volley')
编译'com.android.support:support-v4:19.1.0'
编译com.google .android.gms:播放服务s:+'
compile'c​​om.actionbarsherlock:actionbarsherlock:4.4.0@aar'
编译文件('libs / FlurryAnalytics_3.3.3.jar')
编译文件('libs / crittercism_v3_2_0_sdkonly
编译文件('libs / httpmime-4.2.5.jar')
编译文件('libs / nineoldandroids-2.4.0.jar')
编译文件(' libs / picasso-2.3.3.jar')
编译文件('libs / universal-image-loader-1.8.4.jar')
}
通过com.android.dex.DexException,Android build失败:多个dex文件定义了Landroid / support



解决与排除作为

 依赖关系{
compile fileTree(dir:'libs',include:'* .jar',exclude:'android-support - *。jar')
// ...
}



多个dex文件定义Landroid /支持/ v4 / accessibilityservice / AccessibilityServiceInfoCompat 很容易,因为 exclude module:'support-v4'



例如

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

compile'c​​om.android.support:support-v4:18.0.+'
}

(也发贴到 Gradle排除或添加包含在library classes.jar内的JAR文件的引用


I am migrating my Android code from Eclipse to Android studio and have been stuck at the following error. The project builds fine and syncs with gradle, but it throws the following error on compiling.

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

I have tried to resolve this kind of error with jars and library and have even tried inserting

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

when I had conflicts in the support library. But this seems to be a different kind of error with the build tools. I tried to checkout the inputList.txt file as mentioned in the path /home/Work/Roadblock/Android Studio Projects New/app/build/intermediates/tmp/dex/debug/inputList.txt but found nothing relevent as it is build by the system.

My earlier question (Android Studio not detecting support libraries on Compilation) provides details about the project structure and this seems to be the error after removing the configurations tag from build.gradle. I checked each of the files and libraries used and removed the jars which might have been added multiple times, but this error still persists.

DEPENDENCIES:

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')
}

解决方案

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

Solved with exclude as

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

and

At Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat it easy as exclude module: 'support-v4'

example

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

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

(also posted to Gradle Exclude or add reference for JAR file hard included inside library classes.jar)

这篇关于顶级异常应用程序:dexDebug --dex -no-optimize --output android studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆