0

I have a problem with R in android. I have a project with some packages. I changed the name of one package. I saw that the package with the same name was in "gen" folder. When I changed the name, I cleaned the project and this package disappeared from "gen" folder. Now I have error with

R cannot be resolved

and in all classes I have errors with R. How I can repair my problem?

Swayam
  • 16,294
  • 14
  • 64
  • 102
user1302569
  • 7,131
  • 13
  • 46
  • 66

4 Answers4

2

So i think this is answer

Eclipse sometimes likes to add an "import android.R" statement at the top of your files that use resources, especially when you ask eclipse to sort or otherwise manage imports. This will cause your make to break. Look out for these erroneous import statements and delete them.

Reference.

And try to clean your project and if you have

import android.R;

remove this line and clean it again.

Simon Dorociak
  • 33,374
  • 10
  • 68
  • 106
  • 1
    +1 this should work just fine, Netbeans also has the same thing, why they cant just make the app build itself on creation, so this problem would be no more, really alludes me – David Kroukamp Jun 28 '12 at 17:57
1

remove

import android.R;

and do Project > Clean...

StealthOne
  • 194
  • 9
0

Remove this import from your code if it is there.

import android.R;

Clean your project and rebuild the solution again.

Swayam
  • 16,294
  • 14
  • 64
  • 102
0

If it isn't what the two other answers are, I've had a similar problem that related to me having an error in one of my XML files. Since the XML file has an error, eclipse fails to build your project. A failed build somehow messes up the path to the R.java file. So if you clean up your XML files and build the project, it should fix itself.

JuiCe
  • 4,132
  • 16
  • 68
  • 119