转载请注明来源:http://blog.csdn.net/goldenfish1919/article/details/33729679

用eclispe打包的时候报错:

[2014-06-23 13:44:35 - Dex Loader] Unable to execute dex: Cannot merge new index 66195 into a non-jumbo instruction!

[2014-06-23 13:44:35 - tao_apad_2.0] Conversion to Dalvik format failed: Unable to execute dex: Cannot merge new index 66195 into a non-jumbo instruction!

參考:http://www.cnblogs.com/frydsh/archive/2013/02/20/2918969.html

最新的ADT和SDK Tool在将jar转化成dex的时候,可能会合并类的代码,这将导致巨大的类;类中的每个方法都分配有一个id,字节码中以id标识和调用方法;早期的Dalvik VM内部使用short类型变量来标识方法的id,最大值限制在65535;综合上述因素,代码在安装的时候,不能通过验证,所以安装失败。

最新的Android可能已经攻克了这个问题,可是更早的Android版本号可能仍然存在此问题。

因此,因为大量遗留机器的存在,这个问题是不能彻底解决的,一个暂时的解决方式是:删掉没有实际使用的代码,或者使用ProGuard处理代码(能够减小代码体积)。

一个不幸的推论是:随着一个软件功能的添加,代码的膨胀,APK包终将超出能够处理的范围,或许就是8M(指APK包里面的classes.dex).

參考:https://code.google.com/p/android/issues/detail?id=40409

While the Dalvik team works on a fix, I'm going to allow disabling of the new dex merger features. Builds will be slower (actually back like they were before) but they'll work at least. We were looking at a 21.0.1 release so I'm going to do this now and
make sure this gets in.

然后,改动project.properties,加入一行:dex.disable.merger=true,居然能够了。

文中还有,也是猜的,没有依据:

@18: i think you're confused. there are probably multiple bugs. as i explained in comment 7, the original error is caused by out-of-order annotations. the number of annotations isn't relevant to that bug;all that matters is whether
the method indexes they refer to happen to come out in order or not when the merge basically appends them without sorting. (you are though correct that the annotations problem has nothing to do with jumbo mode --- it's the merge step that's the problem.)

looking at libdex, the reason for your new error is a bit more obscure. it seems to mean that there are references to more than one class in a class_data_item. my assumption is that that means thatone of the fields or methods
referred to in the class_data_item doesn't belong to the class we're supposedly defining.i'm afraid i don't know enough about the merge process to know how/why that might happen.

我们这个问题的解决办法大概是:

Ufnortunately method call is encoded with a method_id being a short int (so only 65535 different methods), unlike const string access.

So, to summarize, even though the .dex specs allows more than 65535 classes and methods, the vm doesn't support large number of classes/methods, there wasn't any explicit error message.

一个vm最多仅仅能有65536个方法!

dex.force.jumbo是干嘛的?

To my knowledge, dex.force.jumbo activates the const-string-jumbo opcode which allows to refer to static strings when you have more than 65k strings in your dex file.

假设超过了65k个字符串,启用dex.force.jumbo这个參数才干够引用到全部的字符串。

usually, dx will use the shortest instruction it can. this can make merging impossible if an instruction would need to be widened to fit more bits of string index (or whatever). dex.force.jumbo says "always use the wide form, even if you don't need to",
to improve the chances of being able to merge later.

dex.disable.merger的官方解释參考:http://blog.toolib.net/tools/sdk/eclipse-adt.html:

Added a flag to disable dex merging to deal with cases where merging could generate a broken dex file. If this happens to your project, add the following setting to your project.properties file: dex.disable.merger=true。This setting causes the build system
to revert to the older, slower dex processing that does not pre-dex libraries.

也就是说merge可能会出问题,详细啥问题,没说,非常操蛋!

昨天还试验出了一种方法,在project.properties文件里加入以下两个选项也是能够的:

manifestmerger.enabled=true

dex.force.jumbo=true

我们的project是由于引入了一个libproject导致的这个错误,因此启用了manifest merge,然后设置dex.force.jumbo居然也能够,详细原因有待于进一步查明。

关于manifestmerger.enabled,參考http://stackoverflow.com/questions/10976635/using-the-new-manifestmerger-property-in-android:

Automatic merging of library project manifest files into the including project's manifest. Enable with the manifestmerger.enabled property.

If you want to merge android library project manifest and your current project manifest, you can add manifestmerger.enabled=true in your project.properties file where you referred your library project. But, you should be confirmed some point like ADT version,
Also Minimum and target SDK should be same as library project.

因此,这样的方式是有局限性的,Minimum和target SDK须要同样才干够。

Android-Cannot merge new index 66195 into a non-jumbo instruction的解决的方法的更多相关文章

  1. Android-Cannot merge new index 66195 into a non-jumbo instruction的解决办法

    转载请注明来源:http://blog.csdn.net/goldenfish1919/article/details/33729679 用eclispe打包的时候报错: [2014-06-23 13 ...

  2. Android中新建的文件在R没有显示相应的文件解决的方法总结

    我们有时会发现当我们新建一个文件或者目录在Generated Java Files(gen)文件的R.java中没有生成相应的静态类或者静态属性.此时你可能出现了以下的情况.注意參照解决. 一般正常情 ...

  3. 我的Android进阶之旅------>Android字符串资源中的单引號问题error: Apostrophe not preceded by 的解决的方法

    刚刚在string字符串资源文件里,写了一个单引號.报错了,错误代码例如以下 error: Apostrophe not preceded by \ (in OuyangPeng's blog ) 资 ...

  4. 解决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 ...

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

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

  6. Cannot merge new index 65781 into a non-jumbo instruction! 问题解决(网上摘抄)

    我的报了这个错 Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.buil ...

  7. [转]Android通过NDK调用JNI,使用opencv做本地c++代码开发配置方法

    原文地址:http://blog.csdn.net/watkinsong/article/details/9849973 有一种方式不需要自己配置所有的Sun JDK, Android SDK以及ND ...

  8. mint/ubuntu Android Eclipse ADT 简单安装及执行崩溃解决的方法

    1. 下载 Android SDK(ADT Bundle)     http://developer.android.com/sdk/index.html     (站点訪问不了或者慢.请參考:轻松改 ...

  9. android开发找不到模拟器(PANIC: Could not open:)解决办法

    android开发找不到模拟器(PANIC: Could not open:)解决办法   2013/4/3 17:44:15 0人评论 213次浏览 分类:android开发 在系统环境变量设置名为 ...

随机推荐

  1. 互联网创业十问?good(快速迭代、把握核心用户应对抄袭,不需要把商业模式考虑完备,4种失败的信号,失败者没资格说趁着年轻...)

    著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.作者:曹政链接:https://www.zhihu.com/question/20264499/answer/28168079来源: ...

  2. AzureDev 社区活动获奖者公布

    今天,我们高兴地宣布 AzureDev社区活动的获奖者,并向这 5 个非盈利技术教育组织发放 10 万美元奖金.在 2013 年的Build大会上宣布的 AzureDev 活动专注于通过代码改变世界, ...

  3. 【JSP】JSTL核心标签库的使用方法和示例

    JSTL 核心标签库 JSTL 核心标签库标签共有13个,功能上分为4类: 1. 表达式控制标签:out.set.remove.catch 2. 流程控制标签:if.choose.when.other ...

  4. 数据挖掘算法学习(三)NaiveBayes算法

    算法简单介绍 NBC是应用最广的分类算法之中的一个.朴素贝叶斯模型发源于古典数学理论,有着坚实的数学基础,以及稳定的分类效率.同一时候,NBC模型所需预计的參数非常少,对缺失数据不太敏感,算法也比較简 ...

  5. 软件顾问可视设计的得力助手——PowerMockup

    你可能是一位从事信息化的软件顾问,你也可能是一位软件设计师,你须要通过图形直观的向客户表达你的设计意图. 你可能已经积累了非常多的Powerpoint图形元素,但每次都要从以往的文件里到处寻找,浪费您 ...

  6. T-Sql中的pivot和unpivot

    写在前面 今天休息,抽空了解下pivot和unpivot,记得老师讲行转列的时候,貌似提到过,不过他说的最多的就是“这个你们私下可以自己学,很简单的...”,简单你咋不讲呢,不吐槽他了,还是好好整理下 ...

  7. 02-Foundation-NSMutableString、NSNumber、NSValue、NSDate、NSArray

    目录: 一.NSMutableString可变字符串 二.NSNumber数字对象 三.NSValue 四.NSDate日期对象 五.NSArray数组对象 回到顶部 一.NSMutableStrin ...

  8. Jquery学习笔记:获取jquery对象的基本方法

    jquery最大的好处是将js对html页面的操作(读写)进行了封装,隔离了浏览器的差异性,并简化了操作,和提供了强大的功能. 在web页面中,所有的js操作都是围绕操作dom对象来的.而jquery ...

  9. HDU4707:Pet(DFS)

    Problem Description One day, Lin Ji wake up in the morning and found that his pethamster escaped. He ...

  10. 四大流行的jdbc连接池之C3P0篇

    C3P0是一个开放源代码的JDBC连接池,它在lib目录中与Hibernate一起发布,包括了实现jdbc3和jdbc2扩展规范说明的Connection 和Statement 池的DataSourc ...