NoClassDefFoundError - Eclipse and Android

后端 未结 27 966
夕颜
夕颜 2020-11-22 08:02

I\'m having a problem trying to run an Android app which, up until adding a second external library to its build path, was working fine. Since having added the scoreninja ja

相关标签:
27条回答
  • 2020-11-22 08:46

    I had this problem and it was caused by not "exporting" the library.Issue was just because the .class files for some classes are not available while packaging the APK.Compile time it will work fine with out exporiting

    In my case I was using "CusrsorAdapter" class and under "JavaBuildPath->Order and Export" I didn't check the support V4 jar.Once it is selected issue is gone.

    To make sure you are getting noClassDefFound error because of above reason, please check your logacat, you will see unknown super classs error at run time.

    0 讨论(0)
  • 2020-11-22 08:47

    All the existing answers don't work for me because my case is a little bit different. It took me a few hours to get it to work. I'm using Eclipse.

    My android project includes another normal java 1.6 project, which needs a 3rd party jar file. The trick is:

    • include the jar in the normal java project for it to compile (only), don't check it in the "Order and Export" tab
    • also copy this jar file into the "libs" folder of the android project so it'll be available in runtime

    Hope this help those who have similar scenarios like mine.

    0 讨论(0)
  • 2020-11-22 08:48

    By adding the external jar into your build path just adds the jar to your package, but it will not be available during runtime.

    In order for the jar to be available at runtime, you need to:

    • Put the jar under your assets folder
    • Include this copy of the jar in your build path
    • Go to the export tab on the same popup window
    • Check the box against the newly added jar
    0 讨论(0)
  • 2020-11-22 08:48

    This happens quite very often to me.

    Last time that happened I can remembered was caused by switching the Eclipse ADT (Google special edition) to Android Studio, and switching back. I basically tried all methods that I can found on stackoverflow which didn't work for me.

    Eventually, I got the app working again (no more NoCalssDeffoundError) by switching my IDE to original Eclipse (Kepler) with ADT.

    0 讨论(0)
  • 2020-11-22 08:51

    I didn't have to put the jar-library in assets or lib(s), but only tick the box for this jar in Properties -> Java Build Path -> "Order and Export" (it was listed before, but not selected)

    0 讨论(0)
  • 2020-11-22 08:51

    I have changed the order of included projects (Eclipse / Configure Build Path / Order and Export). I have moved my two dependent projects to the top of the "Order and Export" list. It solved the problem "NoClassDefFoundError".

    It is strange for me. I didn't heard about the importance of the order of included libraries and projects. Android + Eclipse is fun :)

    0 讨论(0)
提交回复
热议问题