Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newly created layout files not added to R.java

Tags:

android

layout

I have tried literally everything to figure out why no new layout files are being added to my R.java file in eclipse. Nothing is working.

I have:

  • Restarted Eclipse
  • Used Project>Clean
  • Deleted R.java (had to restore because it would not autoregenerate no matter what I did)
  • Ensured all methods are defined in SDK version
  • Rebuilt the project
  • Unchecked auto-build
  • Every combination of above options
  • Been tempted to throw my computer across the room

Does anyone have any suggestions?

like image 234
Gaege Avatar asked Mar 09 '11 20:03

Gaege


5 Answers

Check you don't have any errors inside one of your xml files. That is, check not only for xml file name errors but also for errors in the xml code, for example an illegal attribute, a forgotten tag etc. Check this in all your xml files, not just layout files but also anim, xml drawables etc. These errors don't show up in the error log but will prevent the R.java from being generated.

When I experienced the same issue as you this was often the reason. The error highlight was only visible inside the file, not the error log.

Net, go through every xml file with a fine comb.

like image 89
onosendai Avatar answered Nov 20 '22 01:11

onosendai


I faced this kind of problem many times. From my thoughts it is caused due to the problem of images in the drawable or case sensitive of layout file (everything should be small). Check your case sensitive of layout file.

like image 45
Harikrishnan R Avatar answered Nov 20 '22 01:11

Harikrishnan R


I will give all possible solutions that i had done when something like this happened with me

  1. Project-->clean
  2. Check for library if there was any for that RightClick-->Properties-->Android-->add
  3. Restart Eclipse
  4. Check in the manifest for if you have many packages make sure u are using the activity declared package.
like image 38
Terril Thomas Avatar answered Nov 20 '22 00:11

Terril Thomas


I would check the imported R. The problem could be that you have

import android.R;

instead of

import com.myproject.R;
like image 3
Bassam Mehanni Avatar answered Nov 20 '22 00:11

Bassam Mehanni


Project -> and check Build Automatically

like image 2
Artyom Kiriliyk Avatar answered Nov 20 '22 00:11

Artyom Kiriliyk