您的位置:首页 > Web前端

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

2013-12-05 11:38 591 查看


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

分类: Android 动手操作2013-11-12
19:31 4404人阅读 评论(7) 收藏 举报

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
plaincopy

-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帖子中的:

[html] view
plaincopy

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

[html] view
plaincopy

<?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>

调整之后如下:

[html] view
plaincopy

<?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文件中的:

[html] view
plaincopy

<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、重新编译运行。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: