开发者

R cannot be resolved to a variable

other answers relating to this did not 开发者_开发技巧help me out. Hence, I am posting a new question. I am trying to test a sample app of android that comes with their SDK. I get the error "R cannot be resolved to a variable". Looks like my R.java is not being generated. I don't know if I checked in the right place. I checked in the 'gen' folder of where I had downloaded my SDK and could not find the R.java file in the app which I am trying to test.

Could you please provide me with some ideas?

Thank you so much.


It happens when resources are not compiled. If you don't use automatic builds then just build your project. Otherwise it may happen because of some errors in resources.


I had the same problem(there was nothing under gen folder) and tried other solutions such as "cleaning project, checking if not android.R package is imported instead of mypackage.R, moving gen folder over src in java build path => order export tab and checking permissions of SDK executables" but none of them solved it.

Finally when I was checking one of the layout xml files in the res=>layout whether it has a problem or not Eclipse warned me with "The project target (Android 2.3.3) was not properly loaded" text. So I wanted to double check Android SDK Manager from Eclipse and found out that related SDK had an update. I did not see it before because it has a confusing structure with new or installed check boxes in my opinion.

When the 2.3.3 SDK updated all the problems gone...


Just clean the project and build again.

This is the most common problem I've found while developing for android.

Also try this Link for a detailed description about this issue.


Try to remove the read only in the properties of the sample sdk folder. That fix my problem i guest. Then remove the project in the eclipse. Restart eclipse. Then import it again.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜