Import cannot be resolved even after adding to build path and cleaning

11,954

Solution 1

Maybe it should be org.apache.http.client.HttpClient - HttpClient which is packaged with Android.

Solution 2

Check that the jar contains the exact class at the specified package. You can expand the referenced libraries node to do this.

Also it's likely it should be:

import org.apache.http.client.HttpClient;

import org.apache.http.client.methods.HttpPost;

Solution 3

I think you have added the same jar file couple of times in your build path, which is causing error. Compiler is not able to detect which library to refer as both of them are same and contain same import path. Please remove any one of them and try again.

Solution 4

I had exactly the same problem Steps you need to take 1)Download Binaries from HttpClient 4.2.5 2)then extract it.
3)Start your eclipse. 4)right click on the project where you want these libraries to work>Properties>Libraries(Tab)>Add External Jar> now a window appears where you have to go to the place where the file was extracted. next go inside that extracted folder. next go inside the folder lib. select "all" jar and click OK. I hope your problem will be solved after this.

The problem above is your import is incomplete. I came to know about this when i read the readme in this file. it says


" HttpClient main module requires Java 5.0 compatible runtime and depends on the following external libraries:

  • Apache HttpComponents HttpCore
  • Apache Commons Logging
  • Apache Commons Codec

(for detailed information on external dependencies please see pom.xml)

HttpMime module is optional and requires Java 5.0 compatible runtime and depends on the following external libraries:

  • Apache HttpComponents HttpCore
  • Apache Commons Logging

(for detailed information on external dependencies please see pom.xml) "


Share:
11,954
Displaced Hoser
Author by

Displaced Hoser

Lifelong Canadian, somehow about to become American. Mac fan but not iOS fan. Helping professors with technology by day, getting a CS degree by night. Tech geek, no longer in the closet about it. Also a geek for: philosophy, music, LARPing, languages, Buddhism.

Updated on June 05, 2022

Comments

  • Displaced Hoser
    Displaced Hoser almost 2 years

    I'm having a rough time getting the Apache HttpClient jar libraries imported in the Eclipse ADT. I downloaded the jars. I added them to the project internally and to my build path, and cleaned the project. I kept getting the "import org.apache.commons.httpclient cannot be resolved" message. I tried adding them as an external jar, cleaning the project again, and closing and reopening Eclipse for good measure. No luck. It still has no idea that the jars are there. I feel like there's something basic I'm not doing, but I can't figure out what it is. It seems that most of the time that someone has a problem like this, what fixes it is doing one of the things that I've already done and hasn't worked.

    screenshot

  • Displaced Hoser
    Displaced Hoser about 11 years
    Removed the second one from the build path, cleaned the project. No luck. Same error it's always given me.
  • Displaced Hoser
    Displaced Hoser about 11 years
    Ah, THAT was it - I think I was going from old sample code that used the wrong classes. Thanks.
  • Ankur Shanbhag
    Ankur Shanbhag about 11 years
    Ohh, then remove those imports and let eclipse import them on its own. Press ctrl+shft+o and let eclipse import.