Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse/Android can't generate R files for any project

I am a new Android developer (4 weeks into porting my iPhone app to Android). I have 8 projects (the app, and 6 small UI experiments, and a vanilla Hello World project that I just created with Eclipse). All fail to compile, and the issue is that every reference to the generated file R is flagged as "R cannot be resolved to a variable".

Up until yesterday afternoon -- every project compiled and ran (albeit very slowly) in the Android emulator. I've changed something, and since yesterday, all projects fail to compile, all in the exact same manner "R cannot be resolved to a variable". I every case, the generated files are missing. I believe they disappeared as I tried to clean and rebuild each project in the course of debugging this problem.

Two things that I know changed when this problem started, but that I can't say caused the problem, were: 1) shifting to debugging on a real Android device (a Samsung Galaxy Tab 2, which worked like a champ after struggling with the slow emulators), and 2) allowing Android (and perhaps Eclipse) to update themselves from the web.

I've spent many hours trying other user's suggestions and none have helped. Most suggestions refer to file naming issues, xml syntax errors, but I haven't changed these files and filenames since compilation was working. I have tried:

  • cleaning and rebuilding the projects
  • checking for subsequent updates to the Android SDK (and there were 2 subsequent ones)
  • Eclipse->File->Android Tools->Fix Project Properties
  • making small source changes to force rebuilding
  • rebooting Eclipse, as well as the Mac host, adb, the emulator, the Android SDK Manager
  • deleting a project, restarting Eclipse, and adding the project back in (bad idea - this fails with an error "Failed to load properties file for project 'ListViewFragmentTest'"
  • creating a brand new Android App project, which has worked many times before, but now fails

There's something going systematically wrong, and while I won't claim all these projects are bug-free, they did run up until 6pm yesterday, and then all stopped compiling thereafter.

I wonder if anyone has other suggestions, before I embarking with a complete reinstall of the development environment?

My environment is:

  • Macbook Pro (OS X 10.7.5, 8GB RAM, 2.53GHx Core i5)
  • Eclipse (Indigo Service Release 2, Build: 20120216-1857) (too old?)
  • Android SDK Manager Rev 22
  • Android SDK Tools (22), Platform Tools (17), Build Tools (17)
  • API's 11-17, all up-to-date

Seems like lots of people experience trouble with missing generated files (R), and I have had trouble when I've had layout XML errors as well, but that doesn't seem to be causing this problem. Thanks in advance for your help!

like image 448
user2395611 Avatar asked Dec 08 '22 15:12

user2395611


1 Answers

I am not sure but you are facing issue of R.java file is not getting generated after updated with ADT rev 22.

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.

enter image description here

like image 177
Paresh Mayani Avatar answered Jan 29 '23 04:01

Paresh Mayani