I’ve been fiddling around with making my own Android apps and I keep running into an issue with my IDE. Out of nowhere it will forget what “R” is and start displaying the error “R cannot be resolved to a variable” and upon hovering over the line it suggests adding a reference to android.R, which does nothing to solve the problem. When I was first starting this caused me to abandon a few project files I had started because I had nothing worth saving and it was just easier for me to start a new project. I figured the answer was some typical pain in the butt java thing like setting the Path properly but it actually turned out to be much simpler.
The issue can most often be solved by going to Project and then Clean in your IDE. After cleaning the project do a fresh build (Ctrl+B) and you should be good to go. Wow, it’s not often that a Java IDE issue is that easily fixed 🙂
A seasoned Senior Solutions Architect with 20 years of experience in technology design and implementation. Renowned for innovative solutions and strategic insights, he excels in driving complex projects to success. Outside work, he is a passionate fisherman and fish keeper, specializing in planted tanks.