Approach for fixing NoClassDefFoundError? [duplicate]

时光毁灭记忆、已成空白 提交于 2019-11-28 13:36:00

It seems this is thrown when a class is visible at compile time but not at run time... how can this happen?

The build classpath may include JARs that are not being packaged into the APK.

Is it possible or desirable to statically bind at compile time to avoid the problem?

It is possible, desirable, and necessary.

Outside of Eclipse, you just put the JARs you need in libs/ in your project, compile with Ant, and you are done.

Inside of Eclipse, one pattern I have had students use with success is to put the JARs you need in libs/ in your project, add them as JARs to the build path (note: not external JARs), and they get packaged as part of the APK. Note, though, that I do not personally use Eclipse, and so my experience with it is limited.

user1215183

For those having problem I was having the same error with my app. what I did to solve that was create a new project and copy my resource and source folders along with my manifest file into the new project (I deleted in advance those within the new project created) and voila.

When I got this, the problem was actually deeper in the queue; Dalvik converter had failed to convert some of the referenced libraries and still Eclipse allowed me to launch the project.

Check the Android SDK console to see if there are any errors reported.

In my case, I'm using my own library (MyLib) shared between 2 apps. App A was closed when I added a new class to the library.

When I opened App A to work on it, Eclipse recognised the new class, and I was able to reference it. However on running I got the error.

It turned out that the imported library folder in App A (named something like MyLib_src) didn't reflect the changes made to my library project (MyLib).

  • To solve this I refreshed App A, the changes reflected, and Android could build my project correctly.

I have found no reference to this version of the problem, so thought I would add it to this list.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!