Eclipse giving error, missing R.java file after recent update

87,713

Solution 1

After updating to SDK Tools to rev. 22 for the first time, you may need to relaunch Android SDK Manager again and install a new item: Android SDK Build-tools. enter image description here

After installing this, clean your projects and rebuild.

Solution 2

Yesterday, I made an update with sdk manager, and I had the same problem as you. I fixed the issue: I have updated another time the android sdk (with the sdk manager tool), then I check update from eclipse for install the updated ADT plugin and I rebuid my project. "Android sdk Build-tools" from Android sdk manager is now rev 17 and now it is OK. I think the issue is from adt plugin from eclipse

Solution 3

import android.R - remove this statement from all your classes and then do a clean your R file will be generated. if this did not work then check all your xml files for any errors and then do a clean. These 2 are the most common reasons for R file to go missing

Solution 4

Changes in your Build target also can effect R.java in Eclipse so

Right Click Project >> Properties >> Android >> Select Latest(usually) Android API Platform >> Click OK

Hope this is helpful.

Solution 5

Follow These steps...

  1. Right Click Your Project.
  2. Select Properties->Android Check Project Build Target and API Level.
  3. Again come back and open Android Sdk Manager Chekc the Tools and make sure you are installed Curresponding Android SDK Build Tools.

Eg : IF you selected api level 17 in properties you should install Android SDK Build Tools 17..

Share:
87,713
Anupam
Author by

Anupam

Android Developer

Updated on February 10, 2020

Comments

  • Anupam
    Anupam over 4 years

    I have updated my SDK and ADT to the latest version, I have also update the Eclipse to Kepler the latest one after Juno.

    My ADT version is 22.0. After this update when I create a new project, I'm getting error, stating R cannot be resolved to a variable. I have imported import android.R;, but it is showing as unused import stating Don't include android.R here; use a fully qualified name for each usage instead.

    Same thing is happening with Mac OS also with the latest update. I have tried renaming activity_main.xml to other name, but still my R.java is not generated.

    Tried all the things which are possible. Cleaned the project, build the whole workspace. Nothing helping.

    I think ADT or Eclipse compatibility is having problem after the update.

    I have updated my whole SDK, here is the screenshot, but same problem is there.

    enter image description here

  • Anupam
    Anupam about 11 years
    Thanks dude, after installing I restarted my system, now it is working fine.
  • dell116
    dell116 about 11 years
    ...can't wait to start using IntelliJ...and I hope performing SDK/ADT updates won't be as much of a headache as it's been with Eclipse!
  • totaam
    totaam almost 11 years
    If your SDK window is missing, see here: stackoverflow.com/questions/4649562/…
  • macio.Jun
    macio.Jun almost 11 years
    Thx, I spent half a day in this damn sdk and adt update. Reopen eclipse suffices, no need reboot pc.
  • XBasic3000
    XBasic3000 almost 11 years
    +1. I encounter this problem just now. added to this, my recent project still having red marks on lines in the code. The fix is to "Right-Click on the project>Android Tools>Fix project properties". :)
  • user1914692
    user1914692 almost 11 years
    @Krauxe. Thank you very much! Once Eclipse was updated, all projects became a disaster. You really save my day! Haha
  • kenyee
    kenyee over 10 years
    Thanks...this was keeping Eclipse from starting up properly...was just stuck on updating ADK library in the pending jobs list :-P
  • Tony Chan
    Tony Chan over 10 years
    Can someone point me to an official source for when they announced this new item (Android SDK Build-tools)? It's so ridiculous they they don't give us any heads-up about changes like this.
  • AndyG
    AndyG over 10 years
    This seems to suggest what the top answer already suggested...Did you Google for the answer and find it on StackOverflow, and then come back and post it here ;-)
  • Narendra Singh
    Narendra Singh over 9 years
    I had the same as mentioned problem, I tried doing your suggestion, found a no of SDK build tools. I installed 3 of them revision - 17, 19 and 21.1.1, but none of them seemed to work, I even restarted eclipse twice and restarted machine once, but that too didn't help me out