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

后端 未结 6 922
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-31 03:19

I am developing an App in Android. It has to be able of take a photo, and to send that photo to a webpage. This is the code:

HttpClient httpclient = new Defa         


        
相关标签:
6条回答
  • 2020-12-31 03:45

    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.

    0 讨论(0)
  • 2020-12-31 03:49

    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.

    0 讨论(0)
  • 2020-12-31 03:50

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

    0 讨论(0)
  • 2020-12-31 03:57

    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.

    0 讨论(0)
  • 2020-12-31 03:58

    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.

    0 讨论(0)
  • 2020-12-31 03:58

    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 :(

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