2

I am building an application. When I cleaned the project using Project > Clean... my R.java file disappeared. I tried to re-generate it, but I couldn't. So I decided to create a new Android project and to copy-paste the content of my Java class file so I created a new project and the new project HAD NO R.JAVA FILE?!?!?!?!? I waited, I cleaned, re-built but no luck. I tried updating Android Plugin but it is the latest version. So my real question is:
Why When I create a new Android project R.java is not generated?

Thanks in advance,
Mateiaru

Chaoz
  • 2,119
  • 1
  • 20
  • 39
  • you should check error view in eclipse. – Iftikar Urrhman Khan May 16 '13 at 17:37
  • sorry but it is not generated in a NEW PROJECT – Chaoz May 16 '13 at 17:38
  • 1
    you try this. since i am not sure i am posting the same as comment. right click on your project. goto properties. Choose java build path. Choose import and export tab. click android private libraries. Also make sure there are no errors in your resource file. This happened to me after updating. – Raghunandan May 16 '13 at 17:40
  • I have no problems in xml file I just CREATEED A NEW PROJECT. Also, I have in the build path everything I need. – Chaoz May 16 '13 at 17:43
  • The project is new, so there mustn't be any errors. – Chaoz May 16 '13 at 17:43

2 Answers2

4

Well, this kind of thing happens a lot with me. Most of the time, the problem is the xml tag that disappears from a xml file. Check if all your xml files have this tag at the beginning of the code:

<?xml version="1.0" encoding="utf-8"?>

If you find any xml files without this instruction in the first line, you have found your problem. I don't know what is causing this strange behavior in eclipse, but nevertheless this is, probably, the cause of your troubles.

legoscia
  • 39,593
  • 22
  • 116
  • 167
rotterick
  • 384
  • 2
  • 5
  • Please!!!!! I told you I created a NEW ANDROID PROJECT, NO EDIT DONE YET¨!!! – Chaoz May 16 '13 at 17:53
  • Also, please check my answer. It is the only one which works in my case (reinstalling always fixes the problem) – Chaoz May 16 '13 at 17:57
  • Perfect thank you, you just saved me hours of sleep and headaches – Dfranc3373 May 22 '13 at 09:02
  • If you do not see R.java file generation upon creating an Android project, then you probably have missed downloading Android SDK Tools in the Android SDK Manager. In eclipse, go to Window-->select Android SDK Manager Once the Android SDKManager window opens, check the Tools folder and install. Once the installation is completed, restart the eclipse IDE. Build your project and you can see the R.java file generated under the gen folder of your Android project. – Nadeem Jan 20 '16 at 14:25
1

If you don't have R.java file, please check this link.

If you still can't do it, here's how to get the R.java:
- Delete Android SDK and Android NDK;
- Delete all AVDs and all SDK data (Win XP: C:\Documents and Settings\UserName\Application Data\android\" or whatever is the path):
- Delete all the projects and uninstall eclipse;
- Re-download and re-install Eclipse and Android SDK & NDK;
- Install Android Plugin;
- Create a new Android Project;
- Done! You have R.java!

PLEASE BE SURE YOU'VE CHECKED THE LINK AND YOU HAVEN'T FIX THE PROBLEM!

I found no other way. Simple Eclipse & Android Plugin bug.

Mateiaru

Community
  • 1
  • 1
Chaoz
  • 2,119
  • 1
  • 20
  • 39