2

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?

Karate_Dog
  • 1,265
  • 5
  • 20
  • 37
  • 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 Answers6

2

check if you have R imported (it shouldn't) delete R (it should generate itself) clean project run

robocoder
  • 113
  • 1
  • 9
2

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

Volo
  • 28,673
  • 12
  • 97
  • 125
  • Done. Just as you said the culprit was the android.R file. thanks – Karate_Dog Aug 22 '11 at 08:01
  • @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
1

Please check the Console. It should contain some error messages which prevent the R file from being generated.

Tony Vu
  • 4,251
  • 3
  • 31
  • 38
1

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.

Doogle
  • 1,236
  • 1
  • 17
  • 17
1

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.

IncrediApp
  • 10,303
  • 2
  • 33
  • 24
1

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)

Aracem
  • 7,227
  • 4
  • 35
  • 72