Error处理:Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException.

Error处理:Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException.


导入Eclipse Android2.X项目后运行,提示报错:


Console中提示:


通过clean up,fix project之后问题均不能解决。


网上还看到有人说,是因为Eclipse stack的问题,调整之后可以解决问题;按此提示,eclipse.ini的内容如下:


[html]  view plain copy
  1. -startup  
  2. plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar  
  3. --launcher.library  
  4. plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502  
  5. -product  
  6. org.eclipse.epp.package.java.product  
  7. --launcher.defaultAction  
  8. openFile  
  9. --launcher.XXMaxPermSize  
  10. 512M  
  11. -showsplash  
  12. org.eclipse.platform  
  13. --launcher.XXMaxPermSize  
  14. 256m  
  15. --launcher.defaultAction  
  16. openFile  
  17. -vmargs  
  18. -Dosgi.requiredJavaVersion=1.5  
  19. -Xms512m  
  20. -Xmx1024m  

重启eclipse之后,运行,问题依旧。

如何解决?


之前也遇到过代码没有错误,就是编译运行时报错的情况。之前是因为引用第三方jar造成的,引用方式不对造成的,结合目前的状况,

后来goolge上看到:http://code.google.com/p/android/issues/detail?id=20398帖子中的:


[html]  view plain copy
  1. Here is differences between old and new:  
  2.   
  3. (old)  
  4. <?xml version="1.0" encoding="UTF-8"?>  
  5. <classpath>  
  6.     <classpathentry kind="src" path="src"/>  
  7.     <classpathentry kind="src" path="gen"/>  
  8.     <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>  
  9.     <classpathentry kind="src" path="andengine_src"/> <!-- NOTICE THIS LINE -->  
  10.     <classpathentry kind="output" path="bin"/>  
  11. </classpath>  
  12.   
  13. (new)  
  14. <?xml version="1.0" encoding="UTF-8"?>  
  15. <classpath>  
  16.     <classpathentry kind="src" path="src"/>  
  17.     <classpathentry kind="src" path="gen"/>  
  18.     <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>  
  19.     <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>  <!-- NOTICE THIS LINE -->  
  20.     <classpathentry kind="output" path="bin/classes"/>  
  21. </classpath>  
  22.   
  23. Also, new .project file does not contain <linkedResources> section  

认为下面调整引用库的方式比较靠谱。于是根据这个思想进行调整项目的.classpath


我的.classpath文件内容如下:

[html]  view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <classpath>  
  3.     <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>  
  4.     <classpathentry kind="src" path="src"/>  
  5.     <classpathentry kind="src" path="gen"/>  
  6.     <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>  
  7.     <classpathentry kind="lib" path="libs/achartengine-1.1.0.jar"/>  
  8.     <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>  
  9.     <classpathentry kind="output" path="bin/classes"/>  
  10. </classpath>  

调整之后如下:

[html]  view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <classpath>  
  3.     <classpathentry kind="src" path="src"/>  
  4.     <classpathentry kind="src" path="gen"/>  
  5.     <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>  
  6.     <classpathentry kind="lib" path="libs/achartengine-1.1.0.jar"/>  
  7.     <classpathentry kind="output" path="bin/classes"/>  
  8. </classpath>  

之后Refresh--->>Clean UP--->>运行项目,一切正常,至此问题解决。


----------

备注说明:

对于这个问题,发现在升级SDK Tool到22.3之后,也就是Android 4.4的SDK及工具之后,加载之前老版本的项目都会出现这个问题。

关键是要将.classpath文件中的:

[html]  view plain copy
  1. <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>  

· 去掉,之后clean up整个项目,再重新编译即可。


后续说明(2013年11月20日):

对于这个问题,最近大家可能比较苦恼,我也发现并不是所有的项目都会出现这个问题,对于具体差异和原因有待以后遇到再深入探究吧。

不过遇到这个问题的项目,凡是经过以下方法处理的都能够正常进行编译和运行。

1、找到你的项目


2、点击右键


3、打开Properties属性项


4、选中左边Java Build Path项,并在该选项中打开Libraries选项卡,如上图中,将Android Dependencies项和Android Private Libraries这两项Remove掉。

5、Clean up该项目

6、重新编译运行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值