eclipse 即使添加到构建路径和清理后也无法解析导入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15591941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Import cannot be resolved even after adding to build path and cleaning
提问by Displaced Hoser
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.
我很难在 Eclipse ADT 中导入 Apache HttpClient jar 库。我下载了罐子。我将它们添加到项目内部和我的构建路径中,并清理了项目。我不断收到“无法解析导入 org.apache.commons.httpclient”的消息。我尝试将它们添加为外部 jar,再次清理项目,然后关闭并重新打开 Eclipse 以进行良好的测量。没运气。它仍然不知道罐子在那里。我觉得我没有做一些基本的事情,但我无法弄清楚它是什么。似乎大多数时候有人遇到这样的问题,解决它的方法是做我已经做过但没有奏效的事情之一。
回答by tenorsax
Maybe it should be org.apache.http.client.HttpClient
- HttpClientwhich is packaged with Android.
也许它应该是org.apache.http.client.HttpClient
-与 Android 一起打包的HttpClient。
回答by Alb
Check that the jar contains the exact class at the specified package. You can expand the referenced libraries node to do this.
检查 jar 是否包含指定包中的确切类。您可以展开引用的库节点来执行此操作。
Also it's likely it should be:
它也可能应该是:
import org.apache.http.client.HttpClient;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPost;
回答by Ankur Shanbhag
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.
我认为您在构建路径中多次添加了相同的 jar 文件,这导致了错误。编译器无法检测要引用哪个库,因为它们是相同的并且包含相同的导入路径。请删除其中任何一个,然后重试。
回答by nsp
I had exactly the same problem
Steps you need to take
1)Download Binaries from HttpClient 4.2.52)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.
我遇到了完全相同的问题 您需要采取的步骤 1) 从HttpClient 4.2.5下载二进制文件
2) 然后提取它。
3)开始你的日食。4)右键单击您希望这些库工作的项目>属性>库(选项卡)>添加外部Jar>现在会出现一个窗口,您必须转到提取文件的位置。接下来进入提取的文件夹。接下来进入文件夹lib。选择“所有”jar,然后单击“确定”。我希望你的问题会在这之后得到解决。
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:
" HttpClient 主模块需要与 Java 5.0 兼容的运行时并依赖于以下外部库:
- Apache HttpComponents HttpCore
- Apache Commons Logging
- Apache Commons Codec
- Apache HttpComponents HttpCore
- Apache 公共日志记录
- Apache Commons 编解码器
(for detailed information on external dependencies please see pom.xml)
(有关外部依赖项的详细信息,请参阅 pom.xml)
HttpMime module is optional and requires Java 5.0 compatible runtime and depends on the following external libraries:
HttpMime 模块是可选的,需要与 Java 5.0 兼容的运行时并依赖于以下外部库:
- Apache HttpComponents HttpCore
- Apache Commons Logging
- Apache HttpComponents HttpCore
- Apache 公共日志记录
(for detailed information on external dependencies please see pom.xml) "
(有关外部依赖的详细信息,请参阅 pom.xml)”