简体   繁体   中英

Android : The Missing R

I have seen alot of cases of "R cannot be resolved to a variable". Though my case is odd. It was working perfectly about 15 minutes ago and within that frame, R has now vanished and cleaning the project won't cut it.

I have also ensured that all of my SDK parts are up to date before and after the incident. And the problem still occurs.

Can anyone figure out a solution as to why it would disappear just like that? Even though the SDK was up to date before R vanished?

And another question. Why does this R file cause so much trouble? (I am using Eclipse btw)

This can certainly be a nuisance.

Make sure any R. imports haven't sneaked their way in. Your imports should be bereft of any 'R.'

If you have changed your package name recently, ensure that AndroidManifest.xml is still pointing to the correct package. Using eclipse to refactor does not guarantee the manifest will update.

A side note, if you have errors in your xml files (layouts etc) this will cause a Resource error. Not all errors will be caught by eclipse, so you have to go through those files with a fine comb.

Sometimes simply cleaning, closing and restarting eclipse can help.

Check if you've recently added some music or pictures (any type of resource generally) to your res folder structure. Name of resource must be in lowercase completely, must not start with number...

Also look at the output in the eclipse console. It sometimes show error messages if it can't generate R.java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM