NoClassDefFondError in Android… but the Class is in one jar included in the Classpath

和自甴很熟 提交于 2019-11-30 08:27:42

you need create a folder named libs in your project, and copy you referenced jars to this folder.

Being unsuccessful at the automatic updating thing, I downloaded the latest and greatest. But the MultipartEntity class couldn't be found. I re-added it to the project. I made sure it was in a folder called 'libs' - but no luck. Andong's prompted me to check the project preferences. Project Properties -> Java Build Path -> Order and Export: make sure that Android Private Libraries is checked. (I checked them all). Clean your project. The problem is gone.

So weird, my app already had the files in "lib" and got this crash. I renamed it "libs" following idiottiger's response and it worked.

Open Properties for your project in Eclipse. And open Order and Export, make sure all libraries you need are selected. And click Project>clean. Finally, your problem should be gone.

I had a few issues with this today:

a) I had all the jar files to the libs directory and went right click on Project > Build Path > Add external jars > selected the jar files. Then went "order and export", still got the issue. b) Turns out that httpclient-4.3.1.jar and httpmime-4.3.1.jar weren't enough. I needed to add httpcore-4.3.jar as well.

That got rid of the error! :D I have spent nearly 4 hours today trying to fix this :(

Vishwanath Kulkarni

I solved the same issue like this:

  1. Open pom.xml in the project you are facing this
    java.lang.NoClassDefFoundError: org/apache/http/entity/mime/MultipartEntityBuilder

  2. Under dependencies, add this piece of code.

      <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.2</version>
            <scope>test</scope>
        </dependency>
    
  3. Clean and rebuild the code.

It will work.

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