同时在工程中引入了多个第三方jar包,导致调用的方法数超过了android设定的65536个(DEX 64K problem),进而导致dex无法生成,也就无法生成APK文件。

解决办法如下:

1、谷歌官方已经给出了相关的文档,参照网上搜索的资料,首先,我的问题是:

Error:Execution failed for task ':duchazhushou:dexRelease'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
C:\Users\jeff\AppData\Local\Android\sdk\android-sdk\build-tools\21.1.1\dx.bat --dex --output D:\dev\android\Duchazhushou_TDT\duchazhushou\build\intermediates\dex\release --input-list=D:\dev\android\Duchazhushou_TDT\duchazhushou\build\intermediates\tmp\dex\release\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)
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:302)
at com.android.dx.command.dexer.Main.run(Main.java:245)
at com.android.dx.command.dexer.Main.main(Main.java:214)
at com.android.dx.command.Main.main(Main.java:106)

2、在项目的build.gradle文件的dependencies 节中添加分包设置:

dependencies {
...
compile 'com.android.support:multidex:'
...
}

3、通过在defaultConfig节中设置multiDexEnabled标签为true,开启multi-dexing支持.

defaultConfig {
...
multiDexEnabled true
...
}

4、分三种情况,由于我并未创建自己的Application.class,直接在AndroidManifest.xml文件的Application声明中添加;

android:name="android.support.multidex.MultiDexApplication"

5、重新build,生成签名APK,安装使用正常。

以上步骤均参考下面链接操作,关于第4步的另外两种情况,在下面链接中均有详细说明:

http://stackoverflow.com/questions/27377080/after-update-of-as-to-1-0-getting-method-id-not-in-0-0xffff-65536-error-i

解决“com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536”问题(l转)的更多相关文章

  1. Android学习笔记----解决“com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536”问题

    同时在工程中引入了多个第三方jar包,导致调用的方法数超过了android设定的65536个(DEX 64K problem),进而导致dex无法生成,也就无法生成APK文件. 解决办法如下: 1.谷 ...

  2. 解决android studio上“com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65935”问题

    我是在更换应用的一个jar包时发生的这个错误,网上查到说是因为同时在工程中引入了多个第三方jar包,导致调用的方法数超过了android设定的65935个(DEX 64K problem),进而导致d ...

  3. Android Unable to execute dex: method ID not in [0, 0xffff]: 65536 问题解决方法

    开始一个新项目的时候,Build工程的时候一直报这个错误: 控制台报错误:Conversion to Dalvik format failed: Unable to execute dex: meth ...

  4. Conversion to Dalvik format failed:Unable toexecute dex: method ID not in [0, 0xffff]: 65536

    关于方法数超限,Google官方给出的方案是这样的:https://developer.android.com/intl/zh-cn/tools/building/multidex.html 我也写过 ...

  5. Unable to execute dex: method ID not in [0, 0xffff]: 65536

    http://ingramchen.io/blog/2014/09/prevention-of-android-dex-64k-method-size-limit.html

  6. [转]預防 Android Dex 64k Method Size Limit

    转载自:http://ingramchen.io/blog/2014/09/prevention-of-android-dex-64k-method-size-limit.html 08 Septem ...

  7. 解决Error:Android Dex: com.android.dex.DexIndexOverflowException: Cannot merge new index 65918 into a

    错误:Error:Android Dex: com.android.dex.DexIndexOverflowException: Cannot merge new index 65918 into a ...

  8. com.android.dex.DexIndexOverflowException: Cannot merge new index 66299 into a non-jumbo instruction

    打包时控制台输出: Error:Execution failed for task ':app:transformClassesWithDexForAll32Release'. > com.an ...

  9. 解决com.android.dex.DexException: Multiple dex files define Lcom/google/gson/JsonSerializer;

    我在开发Windows Azure的Mobile Service(隔天补上创建过程)的安卓客户端时,报出了com.android.dex.DexException: Multiple dex file ...

随机推荐

  1. p7 struct and union

    struct  StudentRec           //①声明结构体类型StudentRec{        char StuNum[20];        //②定义结构体的成员变量      ...

  2. Sql语句,先查询再插入一条语句完成。

    if ( (select COUNT(*) from Hr where 考勤号码 = '149' and 日期时间 = '2015/7/3 12:00:26') = 0 )INSERT  INTO [ ...

  3. Asp.Net Web API 2第二课——CRUD操作

    详情请查看http://aehyok.com/Blog/Detail/69.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本文文章链接:ht ...

  4. 《JavaScript高级程序设计》学习笔记12篇

    写在前面: 这12篇博文不是给人看的,而是用来查的,忘记了什么基础知识,点开页面Ctrl + F关键字就好了 P.S.如果在对应分类里没有找到,麻烦告诉我,以便尽快添上.当然,我也会时不时地添点遗漏的 ...

  5. C++中虚析构函数作用

    我们知道,用C++开发的时候,用来做基类的类的析构函数一般都是虚函数.可是,为什么要这样做呢?下面用一个小例子来说明:        有下面的两个类: class ClxBase{public:    ...

  6. Twitter API升级至1.1

    Twitter API 1.1是至今最大的一次升级,从3月份提出,到6月11日1.0版本已经全面停止调用.关于1.1版本升级特性可访问: https://dev.twitter.com/docs/ap ...

  7. autohotkey在运维中的应用

         AutoHotkey是一个自由.开源的宏生成器和自动化软件工具,它让用户能够自动执行重复性任务.AutoHotkey可以修改任何应用程序的用户界面(例如,把默认的Windows按键控制命令替 ...

  8. Working With Taxonomy Field in CSOM

    How to create taxonomy field with CSOM If you need to programmatic create a taxonomy field, you need ...

  9. Linux-vmware tools安装与cdrom挂载

    前述 昨天想直接复制虚拟机centos系统中命令行的内容到主机的txt文档上进行保存,发现不能实现虚拟机与主机之间的直接通讯,后来查资料发现原来是由于我的虚拟机没有安装vwmare tools的缘故. ...

  10. django with mysql (part-3)

    step01: write second view-function vim views.py step02: configure your ( urls.py ) vim urls.py step0 ...