gradle build错误:任务执行失败':core-app:dexDebug'

时间:2014-09-01 15:10:23

标签: android gradle build-process

所以看起来我有一个传递依赖,我无法解决。 我的核心应用程序模块依赖于另一个模块(B),另一个模块(A)也依赖于B.这样的事情:

core-app depends_on module_B

core-app depends_on module_A

module_A depends_on module_B

搜索后,我看到了这个解决方案:UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define 并尝试了这个:

configurations {
    all*.exclude group: 'my.package', module: ':module_B'
}

但是当我尝试运行应用程序时,我仍然有这个丑陋的错误:

Error:Execution failed for task ':core-app:dexDebug'.
  

com.android.ide.common.internal.LoggedErrorException:无法运行命令:       / Applications / Android Studio.app/sdk/build-tools/20.0.0/dx --dex --num-threads = 4 --output / dev_workspace / android-app / core-app / build / intermediates / dex / debug   / dev_workspace /机器人应用内/核心应用内/建造/中间体/类/调试   / dev_workspace / Android的应用程序/核心应用程序/构建/中间体/依赖缓存/调试   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/classes-197cbd736ad01e53c31276271ae913486b0abf5b.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/classes-3c3136b1a3d2e071fc0b25f37c5115244438cb45.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/classes-6e775e8dcfd81b4448a33f89f29368ec66cde279.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/classes-bd82247962e0da24f39e8f7dbf7adc766a7f8ea4.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/classes-c5a1782afffa13143ca90626baf46256b7521223.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/comscore-501f7ccbcd2ef08a3b81c85e45538f5e5bb8db72.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/content-release-unsigned-5915579628ca7ffd706dfd83d8791a6900d71b88.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/core-0de7b51c98dd9c35c27949289c8a48ba50cde798.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/gcm-551b250131d562313127ab0d990e96fdc83abe51.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/HockeySDK-3.0.1-cffb40375ed4edee500e0b998409b63fe76a13f6.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/infonlinelib_private-58b4cfaa6af1eeaca7c757fb9828fac11d7c99eb.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/internal_impl-21.0.0-rc1-24afc028a4165dd5855f9a234d828ba29d5b9b2e.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/jackson-core-2.2.3-03093703b9b63dae474edd11807c8fc1887274ab.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/library-1.2-5c388324ca54c5bd1f0edc8032aa1897feff9314.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/markdownview-1.2-303e1a11db64cd2119d013dc06e05520f8f1da36.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/picasso-2.1.1-2f0e493d5aefe82c2c095fb8a9c79a7d097af978.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/signpost-commonshttp4-1.2.1.2-69e9ce27885ad5e375621d00878eb8e692a5322d.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/signpost-core-1.2.1.2-f3438b2714532c18e609a09850c8541be9e1b0a5.jar   /dev_workspace/android-app/core-app/build/intermediates/pre-dexed/debug/support-annotations-21.0.0-rc1-9da56907a54bc62b80b021d0066dc3e5625c73ba.jar     错误代码:       2     输出:       意外的顶级例外情况:       com.android.dex.DexException:多个dex文件定义Lmy / package / Animations;           在com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)           在com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)           在com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)           在com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)           在com.android.dx.merge.DexMerger.merge(DexMerger.java:188)           在com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)           在com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)           在com.android.dx.command.dexer.Main.run(Main.java:230)           在com.android.dx.command.dexer.Main.main(Main.java:199)           在com.android.dx.command.Main.main(Main.java:103)

任何人都知道我做错了什么?

1 个答案:

答案 0 :(得分:0)

好的,我想我发现了问题。 module_A在将其更改为库(apply plugin: 'com.android.application')后被定义为应用程序(apply plugin: 'com.android.library'),它似乎有效。在我看来,这很奇怪。如果您有任何更好的解释,请不要犹豫,分享。