Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R cannot be resolved to a variable (new android project) [duplicate]

This happens for a new project too!

The gen folder is empty. No errors in activity_main.xml file.

I have tried:

  • Project->Clean
  • Project->Properties-> check android version
  • Project->Build
  • Re installing eclipse (latest)
  • Re installing ADT plugin (latest)
  • commenting lines: setContentView(R.layout.activity_main); and getMenuInflater().inflate(R.menu.main, menu); and building project

but still the gen folder is empty! help!

like image 669
Frozen Crayon Avatar asked May 17 '13 18:05

Frozen Crayon


2 Answers

This solved my problem: Eclipse giving error, missing R.java file after recent update

It was the latest ADT update. After the update we need to install android sdk build-tools.

like image 171
Frozen Crayon Avatar answered Oct 12 '22 02:10

Frozen Crayon


I assume you have updated ADT with version 22 and R.java file is not getting generated.

If this is the case, then here is the solution:

Hope you know Android studio has gradle building tool. Same as in eclipse they have given new component in the Tools folder called Android SDK Build-tools that needs to be installed. Open the Android SDK Manager, select the newly added build tools, install it, restart the SDK Manager after the update. Got this answer from this link. Eclipse error: R cannot be resolved to a variable

It's working for me now

like image 44
stickypens Avatar answered Oct 12 '22 02:10

stickypens