Android libraries not found

后端 未结 8 1280
失恋的感觉
失恋的感觉 2020-12-09 10:37

In my android project I am writing a program to connect to a server and below are the libraries that I need to use.

But I get an error saying the following cannot b

相关标签:
8条回答
  • 2020-12-09 11:04

    I know this is an old thread but it make be worth mentioning that these jars are now included in the eclipse Android ADT bundle (for MAC anyway, I have not checked for Windows). You do need to check the version is the one you want, but if it is you are good to go.

    This means you can add them to your project without having to download them separately first - just follow these steps:

    First right click your project and select properties as shown below:

    enter image description here

    Then select Java Build Path from the pop up window:

    enter image description here

    and now select the 'Libraries' tab:

    enter image description here

    and click on 'Add external JARS' and navigate to your ADT bundle/sdk/tools/lib/httpclient (httpmime etc), and then just click open:

    enter image description here

    You also need to import the Jar file itself into your project. I found the best way to do this was to simply copy the JAR files into the 'libs' folder in your project - i.e. CTRL C and CTRL V, or normal drag and drop file copy. To be safe I would refresh (right click project and select refresh - see menu in first picture above) and then clean your project.

    Note if you do the Build Path part above correctly but forget to add the JAR files themselves into your 'libs' folder, you will get an error like: 'Caused by: java.lang.NoClassDefFoundError: org.apache.http.entity.mime.content.FileBody'.

    To resolve this just copy the jar files into the 'libs' folder in your project.

    You should now be good to go!

    0 讨论(0)
  • 2020-12-09 11:05

    try to download it from HttpClient Downloads

    0 讨论(0)
  • 2020-12-09 11:06

    Download the jars from the apache commons site and add them to project and path.

    [Edit] now in Apache HttpComponents http://hc.apache.org/downloads.cgi

    0 讨论(0)
  • 2020-12-09 11:07

    download the jar from here : http://commons.apache.org/

    install it in your project like this:

    Right click on your project and go to properties. On the left tab go to "java build path". And in that on right go to libraries. Click on add external jars and give the path of the jar and your library is added.

    0 讨论(0)
  • 2020-12-09 11:13

    If you are using android studio add the following import to your code:

    import org.apache.http.entity.mime.content.FileBody;

    The IDE will give you an error under "mime" and ask you if you would like to install the dependancy. So if you say yes it will search for it online and then you can download it to app/build/libs directory. FileBody will then be recognized after this process is complete.

    0 讨论(0)
  • 2020-12-09 11:20

    Add these two dependency

    compile "org.apache.httpcomponents:httpcore:4.2.4"
    compile "org.apache.httpcomponents:httpmime:4.3"
    

    It will work.

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