Android-Cannot merge new index 66195 into a non-jumbo instruction的解决办法
来源:互联网 发布:php 数组转为字符串 编辑:程序博客网 时间:2024/06/11 21:10
转载请注明来源: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
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的解决办法
- Android-Cannot merge new index 66195 into a non-jumbo instruction的解决办法
- [Android Studio]解决Cannot merge new index 68383 into a non-jumbo instruction!的问题
- Cannot merge new index 66501 into a non-jumbo instruction
- Cannot merge new index 67361 into a non-jumbo instruction
- Cannot merge new index 65636 into a non-jumbo instruction
- cannot merge new index 65555 into a non-jumbo instruction!
- Cannot merge new index 65553 into a non-jumbo instruction
- android Cannot merge new index 66221 into a non-jumbo instruction(Android studio)bug
- com.android.dex.DexIndexOverflowException: Cannot merge new index 66299 into a non-jumbo instruction
- Android Cannot merge new index 67208 into a non-jumbo instruction
- Cannot merge new index 66221 into a non-jumbo instruction(Android studio)
- Cannot merge new index 65536 into a non-jumbo instruction! android sutdio 报错方案2
- com.android.dex.DexIndexOverflowException: Cannot merge new index 66078 into a non-jumbo instruction
- com.android.dex.DexIndexOverflowException: Cannot merge new index 68257 into a non-jumbo instruction
- 解决“Cannot merge new index 67208 into a non-jumbo instruction”的问题
- 解决“Cannot merge new index 67208 into a non-jumbo instruction”的问题
- 解决“Cannot merge new index 67208 into a non-jumbo instruction”的问题
- WinCE6.0串口打印函数汇总
- ASP中保留小数点后两位数的方法
- xaml初学(动态生成元素【实例(生成连连看布局)】)
- webview中优酷视频iframe自适应屏幕宽度
- qt5 中文显示问题
- Android-Cannot merge new index 66195 into a non-jumbo instruction的解决办法
- Java生成PDF报表
- 我的九年 IT 路
- 软考的意义
- Java回调函数的理解
- 毛泽东为何说状元很少有真学问
- ThinkPHP3.1新特性之动态设置自动完成及自动验证示例代码
- STM32管脚复用的理解
- 如何设制 select 不可编辑 只读