2010-07-08 71 views
5

我创建了一个Hello World应用程序,但得到这个奇怪的错误:Eclipse - HelloWorld - Android错误?

The project cannot be built until the build path errors are resolved 

我没有改变的项目,突出部分创造了它,并试图运行它。

+1

我重新启动了IDE,现在它工作....我没有碰到任何东西。 – 2010-07-08 17:59:45

+0

好点。我已经更新了我的答案以包含该过程。 – VonC 2010-07-08 18:06:19

回答

2

,以避免恼人的问题,我有3个您指定的目标为我工作的解决方案。

解决方法1)

delete your generated R.java file inside your gen/ folder

方案二)

a)Delete your project from Eclipse (i said ONLY from Eclipse, uncheck option: Delete project contents on disk)

b) import your project to Eclipse: file > Import > Existing Projects into Workspace (Look for your project previously deleted from Eclipse) > Finish.

解决方案3)

make Solution 1 then Solution 2

1

听起来像你缺少一个导入或jar。在项目资源管理器中的项目中,文件图标上应该有一个包含错误的红色x。

2

它可以是一个虚假消息可以通过forcing Eclipse to recompute its library paths

I found the resolution for this at Scott D. Strader's blog .
To summarize the solution I only needed to add a library to my project and then remove it to force Eclipse to perform the necessary actions to resolve the problem. I would post the detailed steps here but I don't want to steal his content.

The resolution was to force a resave of the selected projects (and their .classpath files):

  • Open the project properties
  • Select Java Build Path > Libraries
  • Add a new, arbitrary library (to be deleted later) > OK
  • Wait for the workspace to refresh (or force a refresh of the project)
  • The error(s) will go away
  • Remove the dummy library

注意解决:作为OP提到,IDE的一个简单的重新启动即可足够


或者你居然错过了一个关键的库like a JRE library

I needed to add the JRE library to the project for it to run. Not sure if this was due to the updated version or something else…. Any way this fixed the issue:

  • Project > Properties
  • Java Build Path
  • Libraries tab
  • Click add library
  • Select JRE System Library
  • Next
  • Finish
1

除了列出的答案,还有我见过使用包含在项目的样本时,这个错误出现另外一个场景Android SDK。出于某种原因,生成的R.java文件可能无效或损坏。您可以通过展开Package Explorer中的“gen”文件夹并删除R.java文件来避开它。它会立即重新生成并且错误消失。

1

右键点击你的项目,选择“构建路径”,“配置构建路径” - >然后选择Android 2.2系统,或当你创建项目

0

我有过类似的问题。对我来说简单地关闭模拟器并重新运行该项目的工作