JuiCe
JuiCe

Reputation: 4191

R.java disappeared

I recently downloaded the Android Support Package and have been using it trying to get my application, running at SDK 10, to use a GridLayout.

Anyway, I cleaned my project a few times working on this error in my XML files, and then when I went back to my classes in /src, every single reference to R.* was an error.

This has happened to me before, but it usually fixes itself, and it has not yet. Does anyone know what to do?

The R.java file is no longer in my /gen folder.

Upvotes: 5

Views: 2650

Answers (6)

Mehdiway
Mehdiway

Reputation: 10646

This happens when you have an error in the res folder. Fix the error first, then do :

Project --> Clean --> Ok

Et voila !

Upvotes: 1

Dipali
Dipali

Reputation: 374

Follow following steps :

In Eclipse, => Right Click on Project > Android Tools > Fix Project

By this way, you can fix many common problems which can help generate R.java in gen/R.java file.

Upvotes: 2

Hitesh Patel
Hitesh Patel

Reputation: 2878

You can also try Adnroid Tools>Fix Project. That may help you to create gen/R.java file

Upvotes: 2

D-Dᴙum
D-Dᴙum

Reputation: 7890

There can be several reasons why this occurs. The following I have found happen to me and I have included the steps I took to resolve them.

  1. First step is to try and clean the project (from the Project menu option I believe)
  2. Check there are no errors with your XML files. Sometimes this is obvious from the red 'x' that appears next to an XML filename in the Project exlporer window and sometimes it is not. If it is not obvious check the 'Errors' window (whic is founf in the 'Windows' Menu option
  3. Failing that I have found that by disabling the automatic build option, adding some arbitrary comment to an arbitrary source file, saving the source file, clean the project, remove the comment and then re-selcting automatic build can work too.

Apologies for the approximate locations for some of the Eclipse functions but I am not currently in front of Eclipse to check.

Upvotes: 1

telkins
telkins

Reputation: 10540

Sometimes if there is an error in your XML files R.java won't build. Go through your XML files to make sure that everything is in order (typo, forgetting to close a bracket, etc). When you fix that it should build itself again.

Upvotes: 5

MobileEvangelist
MobileEvangelist

Reputation: 2628

It sometimes happens when you import another project First i suggest you to build it, it will create automatically .

If it's not working then try to create new project from existing source and specify the downloaded project . It worked for me

Hope this works for you let me know..

Upvotes: 5

Related Questions