android studio,gradle dex失败了

我正在尝试使用gradle构建我的 android项目,但我一直在收到这条失败的消息,我真的可以理解,当我不使用gradle时,一切都工作顺利,我做错了什么?
:Wrap:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: method ID not in [0,0xffff]: 65536
    at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
    at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
    at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)
 Failed

FAILURE: Build Failed with an exception.

* What went wrong:
Execution Failed for task ':Wrap:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Users/nirkeren/Downloads/adt-bundle-mac-x86_64-20131030/sdk/build-tools/19.0.3/dx --dex --output /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/dex/debug /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/classes/debug /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/dependency-cache/debug /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/activation-371528ff37ca00b95f4aaa30e7ada077808b4066.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/additionnal-cbe08f392e3489e0bbc657eaa6e1b2c578c8c63a.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/aws-android-sdk-1.7.1.1-1063abd88670acb74ffa18e83bed84e1185d156e.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/classes-00b425e022f3e5825d218bf8230a3518488661ad.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/classes-1536774be9f5f226247f33ff39444641cbae5f17.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/classes-319df0e8b970ed8444fa4ad2a35d7b04d8635cf7.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/classes-3a528328da2ecd26bde330cd6e96a93681e37443.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/classes-88cca99f18ad79854e456d941016a7ba2d89778b.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/classes-b427cc929fd1399dd3b95eb4f41a07465f532aaf.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/classes-b7ec143e0b6817ac519f67d77d80b2574ceaac79.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/crashlytics-a9be38ef9142a13510daa326a3e74e79ec26fe81.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/google-api-client-1.15.0-rc-e5d0bfc007123ab793084359d1ef33a23786b1cc.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/google-api-client-android-1.15.0-rc-91914619bb0c2177957554eee1e41988a12b4111.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/google-api-services-drive-v2-rev76-1.15.0-rc-9fc7b1dbf3fa9980bb1471a02e67a59ea7b0e7e4.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/google-http-client-1.15.0-rc-c609d62345e69e29cff2e79286c99b2287dc1935.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/google-http-client-android-1.15.0-rc-219670662f5d9c8793501be852143a90ad8bcfc9.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/google-http-client-gson-1.15.0-rc-2bc2a42d04283a6e31550ba6fb50a545a295e1d7.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/google-oauth-client-1.15.0-rc-3de236b42e6497978cf52f309ed16c0dd47a7e4a.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/google-play-services-d4c8a0bc9c8586e19cc569471ba95580ff827f24.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/gson-2.1-5dd6330840355abbdb328e202fb7a1b601c11625.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/httpclient-4.0.1-6d6f0a4ccfe934c72fcd285cd0bd138903838075.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/httpcore-4.0.1-651bf829da8a88ebcba183426bdc2a5816a8a8f8.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/jsr305-1.3.9-17a8eef10544db30421f617a1a74033dc44e0b5a.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/libGoogleAnalyticsServices-20f33d61149fc3986571664bce4d5a71b7375d77.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/library-2.4.0-cf8b4e3adb01d32f9c0a19763d14e0d5a6fc58cb.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/mail-368bf8fea3a96aaffa7fe8eb7a39f1c975584527.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/opencsv-2.3-60231b26d86a13ba9a7e4d523848b462313d909f.jar /Users/nirkeren/projects/ONDiGO_1_1_0/Wrap/build/pre-dexed/debug/support-v4-19.1.0-00876ab3fdbf97f4dfe545f08a39e533888e15b1.jar
  Error Code:
    2
  Output:

    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: method ID not in [0,0xffff]: 65536
        at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501)
        at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
        at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
        at com.android.dx.command.dexer.Main.run(Main.java:230)
        at com.android.dx.command.dexer.Main.main(Main.java:199)
        at com.android.dx.command.Main.main(Main.java:103)


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD Failed

解决方法

你的项目太大了.你有太多的方法.每个应用程序只能有65536个方法.尝试减少不必要的方法或将Android支持库更新为21版

相关文章

以下为个人理解,如错请评 CE: 凭据加密 (CE) 存储空间, 实际路径/data/user_ce/ DE: 设备加密 (DE) 存...
转载来源:https://blog.csdn.net/yfbdxz/article/details/114702144 用EventLog.writeEvent打的日志(或...
事件分发机制详解 一、基础知识介绍 1、经常用的事件有:MotionEvent.ACTION_DOWN,MotionEvent.ACTION...
又是好久没有写博客了,一直都比较忙,最近终于有时间沉淀和整理一下最近学到和解决的一些问题。 最近进...
Android性能优化——之控件的优化 前面讲了图像的优化,接下来分享一下控件的性能优化,这里主要是面向...
android的开源库是用来在android上显示gif图片的。我在网上查了一下,大家说这个框架写的不错,加载大的...