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

转载请注明来源: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的解决的方法

时间: 2024-08-02 16:05:53

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

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

我们有时会发现当我们新建一个文件或者目录在Generated Java Files(gen)文件的R.java中没有生成相应的静态类或者静态属性.此时你可能出现了以下的情况.注意參照解决. 一般正常情况R文件都是会自己主动更新的.不能更新的,请检測文件的格式.以图图片为例.似乎android仅仅支持jpg和png格式的图片.这个不太清楚,或者你的图片的名字有汉字或者你的图片的名字有大写字母这些都是不行的. 例如以下的图片格式就是非法的.所以R文件不能自己主动更新 图片1.png //图片不能汉字

Dalvikvm method_id 长度限制(方法量限制)Cannot merge new index 66212 into a non-jumbo instruction。

错误描述: 编译时报错:Cannot merge new index 66212 into a non-jumbo instruction. 错误原因: Dalvik 对 method_id 由一个 short int(2个字节)标识. ,一旦工程方法数超过64k method_id溢出,导致无法编译. 解决方式: 以上问题出现在 SDK tools 21(以前会出现此错误)升级 sdk 之后 将工程文件project.properties中 添加 dex.force.jumbo=true,就可

解决“Cannot merge new index 67208 into a non-jumbo instruction”的问题

在将ADT和SDK Tool升级到最新(分别是21.1和16.0.1)之后,我的一个工程(相对比较大)在编译并运行的时候,出现错误,Eclipse控制台输出如下信息: Unable to execute dex: Cannot merge new index 67208 into a non-jumbo instruction!      Conversion to Dalvik format failed: Unable to execute dex: Cannot merge new ind

项目中用了汉字正则表达式,出现异常:Cannot merge new index 65993 into a non-jumbo instruction

在项目中用了汉字正则表达式,编译并运行,Eclipse控制台输出如下异常信息: Unable to execute dex: Cannot merge newindex 65993 into a non-jumbo instruction!? Conversion to Dalvikformat failed: Unable to execute dex: Cannot merge new index 65993 into anon-jumbo instruction! 解决方法: 将dex.f

android客户端和网站数据交互的实现(基于Http协议获取数据方法)

android客户端一般不直接访问网站数据库,而是像浏览器一样发送get或者post请求,然后网站返回客户端能理解的数据格式,客户端解析这些数据,显示在界面上,常用的数据格式是xml和json. 可以理解客户端其实是一个你自己定义标记语言的浏览器,一般浏览器能解析的是html+css的数据,而android客户端能解析的是xml和json(或者都不是而是你自己定义的火星格式),服务端为了能满足客户端输出这种数据格式的需求,不得不专门针对客户端开发不同于浏览器访问的接口. 开发一个网站的客户端你需

Android安装应用后点击"打开"(Open)带来的问题及解决方式

MainActivity如下: package cc.cc; import android.app.Activity; import android.content.Intent; import android.os.Bundle; /** * Demo描述: * * 一年多前遇到一个问题--->: * 1 客户从GooglePlay上下载了我参与的开发的应用 * 2 下载完成后,点击安装 * 3 安装完成后,在屏幕底部有两个选项"打开"和"完成" * 4 点

Android手机APN设置(中国移动 联通3G 电信天翼),解决不能上网的问题

中国移动 第一步,设置CMNET上网 新建APN 1.名称:cmnet 2.APN:cmnet 3.APN类型:default 就仅仅填写上面3个选项,其它都是默认,不用填写. 第二步,设置彩信 新建APN 1.名称:cmmms 2.APN:cmwap 3.代理:10.0.0.172 4.port:80 5.username:(空着) 6.password:(空着) 7.server:(空着) 8.MMSC: http://mmsc.monternet.com 9.彩信代理:010.000.00

Android Studio 使用 SVN 必然遇到问题:commit ** File out of data 问题解决方法

转载请注明:http://blog.csdn.net/lrs123123/article/details/44829579 Android Studio 的使用已经越来越成为趋势.而结合版本号控制工具svn的使用,也是越来越多企业.团队的最佳选择.本文不介绍怎么配置这些.只分享一下svn commit过程中常常性遇到的问题:commit fail: "**File out of data "  这个问题的解决思路和问题的解决办法 原因:某个你要commit 的文件别人已经commit上

Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead的解决的方法

今天在eclipse里报这个错误: Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead. Please fix project properties 找了一下解决方法: 1. 项目 右键 ->android tools ->Fix Project 2. 假设不能够.检查Project -> Properties->Java Compiler 确认JDK compliance被设置为1.