Eclipse报错:“Invalid layout of preloaded class”
问题描述
在eclipse中创建的JavaSE项目,编译运行都OK,copy到eclipse for android中运行报错:
控制台输出:
Invalid layout of java.lang.String at value
Error occurred during initialization of VM
Invalid layout of preloaded class: use -XX:+TraceClassLoading to see the origin of the problem class
解决方案
- Project --> Properties --> Run/Debug Settings
- 选择JavaSE中要Launching的类 --> Edit --> 选择Classpath栏
- 选中Bootstrap Entries下的Android x.x.x库 --> 点击右侧Remove
- 点击OK
此时,再次运行就OK啦!
原因分析
具体原因我并没有深入研究,猜测是运行JavaSE的项目却引用到了Android的库,所以导致失败,移除android库后,纯java环境就OK了。
有知道详细原因的,可以告知一下,不胜感激!
参考博客:https://blog.csdn.net/u013546757/article/details/51326770