I had two layout files on R.java and I checked it was there on R.java(written on it). But strangely the java class cannot recognize the layout and keep saying that the layout cannot be resolved. I Have Run the project but it keep saying that my project contains error. Is this some kind of bugs?
-
Are you using eclipse? If yes then clean the project from project -> clean.. If issue is going on, make sure you are not importing android.R class in your Activity class. – Pankaj Kumar Aug 22 '11 at 07:54
6 Answers
check if you have R imported (it shouldn't) delete R (it should generate itself) clean project run

- 113
- 1
- 9
Check the import section of your java class. Sometimes Eclipse incorrectly imports android.R
class instead of one generated in your project.

- 28,673
- 12
- 97
- 125
-
-
@Karate_Dog how did you do that.. I mean I dont know how to... I just don't know how to check or where to check imports stated on the answer. – Raf Oct 04 '12 at 16:03
-
@Raf It's the import section at the beginning of the .java file that have compilation errors. – Volo Oct 08 '12 at 14:18
Please check the Console. It should contain some error messages which prevent the R file from being generated.

- 4,251
- 3
- 31
- 38
-
This question had been resolved 3 years ago dude. But here's an upvote – Karate_Dog Oct 23 '14 at 03:43
I had similar issue in Android Studio. A gradle build fixed the issue. Hope a ant/gradle rebuild of the project will fix the broken dependency.

- 1,236
- 1
- 17
- 17
Make sure your XML files have no errors before using anything referenced in the R.java file. R.java isn't built if there are errors in your XML files.

- 10,303
- 2
- 33
- 24
This must be for 2 reason normaly.
You have a error in some xml of your project
You must to clean the proyect (project - clean - clean project)

- 7,227
- 4
- 35
- 72