-1

Example code:

setContentView(R.layout.main);

Error:

R cannot be resolved

There's this error in all the classes files, and I can't get rid of it.

I already checked the XML files, there are no errors.

I already made sure that I didn't accidentally import "android.R".

The problem started when I tried to Clean and Rebuild the project.

Eli Revah
  • 3,626
  • 7
  • 27
  • 33

5 Answers5

1

If you already updated the SDK tools, re-open the SDK manager and check under the "Tools" section that "Android SDK Build tools" are installed and eventually, update them. That made the trick for me yesterday.

edoardotognoni
  • 2,752
  • 3
  • 22
  • 31
0

Check if your R is generated properly inside the "gen" folder.Check if there are any libraries missing which are added as dependencies from project properties. Also make sure that there are no issues which is preventing the app from generating R file. Go to Window > Show view> Problems and it will show you whats missing.

Ajith M A
  • 3,838
  • 3
  • 32
  • 55
0

1) Delete your Gen folder (It will be automatically created afterwards).

2) Clean you project.

See the miracle. :)

Varun Vishnoi
  • 328
  • 6
  • 23
0

Please do the following:

1.Check whether there are errors in your xml file.

2.Try to clean the project and run it.
Subburaj
  • 5,114
  • 10
  • 44
  • 87
  • I already checked for errors in the XML files, and cleaning the project is what ruined it in the first place. – Eli Revah May 17 '13 at 08:28
0

Yesterday, I made an update with sdk manager, and I had the same problem as you. I fixed the issue: I have updated another time the android sdk (with the sdk manager tool), then I check update from eclipse for install the updated ADT plugin and I rebuid my project. "Android sdk Build-tools" from Android sdk manager is now rev 17 and now it is OK. I think the issue is from adt plugin from eclipse

Jarvis
  • 1,527
  • 12
  • 17