开发者

R.java malfunctioning

I created a new xml file, and had an errant ? in it that prevented R.java from regenerating. I tried Cleaning the Project, and Fixing the Project Properties but no luck.

Then I realized the XML was creating the R.java from recreating itself, so I deleted the XML file and the R.java was back.

Now though, I am getting an error on all the calls to R.. calls saying that :

  • cannot be resolved or is not a field

So, for instance I have

setContentView(R.layout.detectlayout);

ERROR: detectlayout cannot be resolved or is not a field

for all of my calls to 'R开发者_C百科.'. Any ideas?

I have tried all of the suggestions on SO already to no luck =/


Look at the 'import' section of your code. Since you deleted your original R, chances is Eclipse help you to fill in the R as com.android.R instead of com.yourproject.R

I also sometimes have problem in Eclipse Resource stuff, sometimes I found turning off and on the "auto buiild" function may help, or simply restarting Eclipse may sometimes help. It's kind of buggy under Mac OS.


This can happen if .R is imported. Eclipse will automatically add it sometimes when you have difficulty with with R.java


first don't bother deleting the R file it not going to make things better only worst lol

as you said you some times need to clean the project when you start modifying resources its good to select the root of your project and do a alt+shift+o to reload all ressources then f5 to refresh the tree then clean the project

you also have to check that eclipse is set to build automatically (Project->build automatically).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜