Android Development Tutorial level: Easy

If you’ve developed apps for the Android OS using the Eclipse IDE for longer than 2 hours, then you’ve met cheery  “r cannot be resolved to a variable” guy. He’s quite a stud in these parts. Loud and talkative, he won’t let you do anything when he walks in

R-cannot-be-resolved man
Image by: aaipodpics

There are a number of ways to deal with him. Below are a few tips on how you can politely send him back to the lonely part of the world he comes from.

1. Check your manifest file [AndroidManifest.xml] for any errors. Resolve them

2. Clean your project [Project > Clean Project]

3. Go to the top of affected classes and make sure that they don’t import android.R;   (Or any variants).  Delete that line

4. Check all your layout files (res/layout/*.xml). Ensure that they have no errors. If they do, resolve them

5. Check your console for any errors. Make sure the console is set to display Android errors. Resolve the errors


6. Right-click on the project and choose ‘Android Tools > Fix Project Properties’

7. If your class is located in, move it to then move it back

If you’ve gotten rid of the guy using something else, do share

Leave a Reply

Your email address will not be published. Required fields are marked *