Hello! The problem is very serious. For quite a long time she wrote the project, and now, he is almost ready, but suddenly this error appears: "Type R cannot be resolved to a variable". I reviewed many forums, everywhere it is advised to make Clean, and then manually Build. But it does not work. The gen folder was as empty as it was, and the errors remained.

    4 answers 4

    Faced the same problem. As recommended by Barmaley, ♦ checked for the presence of the aapt utility in / platform-tools . And she was not there. Found quickly, googling "aapt.exe".

    I found it here , checked it on-line with Dr.Web, no viruses were detected. I put it in / platform-tools , launched Eclipse, returned to all projects except one R.java , made Project -> Clean in the last, then Project -> Build , and everything became good.

    • one
      In the latest update of the android-sdk, the aapt utility was moved from /platform-tools to /build-tools/version and some development environments just did not have time to catch this change. Solved by the creation of symbolic links. - Jofsey

    There are lots of ways to kill R.java generation, for example:

    1. Remove the aapt resource compiler (located in <SDK_HOME>/platform-tools )
    2. Make a mistake in the manifest (the generation starts with the parsing of the manifest, and if there is an error in the manifest, then there will be no generation of R.java )
    3. IDE configuration may fly off (too general, but whoever understands understands)
    4. But you never know - I will add

    At the aapt try running aapt from the command line or through ant by hand, you will spend an amazing evening :) but there will be something to remember.

    In general, try

      I usually get this error when I mess up in XML files, be it Manifest, Layout or any other XML.
      @Barmaley In the second paragraph wrote about the manifesto.

      I advise you to check the correctness of all XML.

        Perhaps this is due to the fact that in the latest update of android-sdk aapt utility was moved from /platform-tools to /build-tools/version and some development environments just did not have time to pick up this change.

        The problem is solved by creating a symbolic link /platform-tools/aapt -> /build-tools/version/aapt . Or you can simply copy the file.