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的内容如下:


-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx1024m

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

如何解决?


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

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


Here is differences between old and new:

(old)
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="gen"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
	<classpathentry kind="src" path="andengine_src"/> <!-- NOTICE THIS LINE -->
	<classpathentry kind="output" path="bin"/>
</classpath>

(new)
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="gen"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>  <!-- NOTICE THIS LINE -->
	<classpathentry kind="output" path="bin/classes"/>
</classpath>

Also, new .project file does not contain <linkedResources> section

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


我的.classpath文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="gen"/>
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
	<classpathentry kind="lib" path="libs/achartengine-1.1.0.jar"/>
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
	<classpathentry kind="output" path="bin/classes"/>
</classpath>

调整之后如下:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="gen"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
	<classpathentry kind="lib" path="libs/achartengine-1.1.0.jar"/>
	<classpathentry kind="output" path="bin/classes"/>
</classpath>

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


----------

备注说明:

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

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

	<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、重新编译运行。

  • 11
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 19
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 19
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值