Karate_Dog
Karate_Dog

Reputation: 1277

The android java class cannot recognize the R file

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?

Upvotes: 2

Views: 1533

Answers (6)

Doogle
Doogle

Reputation: 1264

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.

Upvotes: 1

Tony Vu
Tony Vu

Reputation: 4361

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

Upvotes: 1

Aracem
Aracem

Reputation: 7207

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)

Upvotes: 1

Volo
Volo

Reputation: 29438

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

Upvotes: 2

robocoder
robocoder

Reputation: 113

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

Upvotes: 2

IncrediApp
IncrediApp

Reputation: 10353

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.

Upvotes: 1

Related Questions