2010-07-08 326 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

我有過類似的問題。對我來說簡單地關閉模擬器並重新運行該項目的工作