Eclipse / Android cannot generate R files for any project

I am a new Android developer (4 weeks to port my iPhone application to Android). I have 8 projects (application and 6 small experiments with the user interface) and the Hello World Hello project that I just created using Eclipse. All do not compile, and the problem is that each link to the generated R file is marked as "R cannot be resolved by a variable."

Until yesterday, each project was compiled and launched (albeit very slowly) in the Android emulator. I changed something, and from yesterday all projects will not compile, everything is exactly the same "R cannot be resolved by a variable". In each case, the generated files are missing. I believe that they disappeared when I tried to clean and rebuild every project while debugging this problem.

Two things that, as I know, changed when this problem started, but I can’t say that it caused the problem: 1) switching to debugging on a real Android device (Samsung Galaxy Tab 2, which worked as a champion after struggling with slow emulators) and 2) allows Android (and possibly Eclipse) to update itself from the Internet.

I spent many hours trying other user suggestions, and no one helped. Most of the suggestions relate to problems with file names, xml syntax errors, but I did not change these files and file names since the compilation worked. I tried:

  • project cleaning and restoration
  • Check for subsequent updates to the Android SDK (as well as the next two)
  • Eclipse-> File-> Android Tools-> Fix Project Properties
  • creating small initial changes for a forced rebuild.
  • reboot Eclipse as well as Mac host, adb, emulator, Android SDK Manager
  • deleting the project, restarting Eclipse and adding the project back (a bad idea is a failure with an error) Failed to load the properties file for the project "ListViewFragmentTest"
  • creating a new Android App project that worked many times before, but now does not work

Something is happening systematically wrong there, and until I demand that all of these projects be error-free, they worked until 18:00 yesterday, and then everyone stopped compiling after that.

I wonder if anyone has any other suggestions before I proceed to completely reinstall the development environment?

My environment:

  • Macbook Pro (OS X 10.7.5, 8 GB 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 11-17, all updated

It seems that many people are experiencing problems with missing generated (R) files, and I had problems when I also had layouts of XML errors, but this does not seem to cause this problem. Thanks in advance for your help!

+4
source share
4 answers

I'm not sure, but you ran into a problem . R.java file is not generated after upgrade using ADT rev 22 .

If so, then here is the solution:

Hope Android studio has a gradle build tool. Same as in eclipse, they provided a new component in the Tools folder called Android SDK Build-tools, which must be installed. Open the Android SDK Manager, select the new build tools, install it, restart the SDK manager after the update.

enter image description here

+14
source

Check the Java build path library if the src flag is checked or not.

0
source

If you use any additional libraries, make sure that libs / android-support-v4.jar is the same for the project as well as for the libraries.

0
source

Thanks to everyone. None of these suggestions solved my problem. And although I am curious why this happened, I was more impatient, not having made any progress. I rebooted Eclipse and the Android tools (this time with an added version from developer.android.com) and everything works smoothly again.

0
source

Source: https://habr.com/ru/post/1481477/


All Articles