Error accessing xml file in android

I am new to android programming and recently developed a weird error in my code. I was following a tutorial that directed the coder to go to project>clean (in eclipse). After I clicked it my code developed errors whenever I tried to access a resource. I received an error on the R. It said that the variable R cannot be recognized. Eclipse recommends that I import the package "R" which did not work. An example of the line of code that had the error on is:

setContentView(R.layout.activity_main);

After I imported "R" eclipse was unable to recognize/find activity_main.

Upvotes: 0

Views: 63

Answers (1)

kablu
kablu

Reputation: 659

You can check some steps.

1. resource activity_main layout or others resource ok or not.
2. your activity in above delete import Android.R
3. add your package_name.R for example. if your package name is com.example.helloworld, then import com.example.helloworld.R
4.delete bin folder and gen folder of your project.
5. clean your project , project=>clean.
and 6. finally restart your eclipse.

When any resource mismatch then this type error show.

Best of luck

Upvotes: 1

Related Questions