1

Recently i updated the eclipse software and when i started doing new projectsenter image description here, the R.java file was missing. I copy pasted it from the previous projects but the current project is still giving errors. The errors I am getting are shown in the image. Please help.

This is my SDK manager

enter image description here

vbvs
  • 173
  • 1
  • 1
  • 9
Sherry
  • 325
  • 2
  • 4
  • 13
  • 4
    Have even done a search for this problem? A quick google reveals many answers. Perhaps this will help you http://stackoverflow.com/questions/3232274/r-class-missing-after-creating-android-project-from-existing-source – Stu Whyte Oct 04 '13 at 10:31
  • I think there some problem on your resource that y R file not generated again. – Haresh Chhelana Oct 04 '13 at 10:31
  • 1
    sometimes if you do alot of copy pasting eclipse will put import android.R; in your imports and you get that error, see if its in your imports take it out and clean and rebuild – JRowan Oct 04 '13 at 10:42

5 Answers5

1

Project -> Clean.

This will generate R.java automatically

If it doesn't work, please detach all resource xml file from your project and do above.

And attach xml files again and do above again.

Anti-X_KR
  • 23
  • 4
  • Don't edit R.java by yourself. If you edit it manually it will be broken. – Anti-X_KR Oct 04 '13 at 10:34
  • when i am cleaning the project and building it again, it is giving me an error. it is saying that building workspace has encountered a problem, errors occurred during the build, the error is null pointer exception. – Sherry Oct 04 '13 at 10:48
  • What is your eclipse version and ADT? – Anti-X_KR Oct 04 '13 at 11:15
  • Open activity_phonegap.xml with Android XML Editor (Not general xml editor). If there is a bug in your layout file, editor shows you error point. – Anti-X_KR Oct 04 '13 at 11:23
  • ADT version 21.0.1 Eclipse version 4.2 – Sherry Oct 04 '13 at 11:24
  • yes i did. there are no bugs here – Sherry Oct 04 '13 at 11:28
  • I think you should develop on more older version of eclipse. This is not official stance, but in my opinion latest eclipse is not suitable for developing android. Latest build of eclipse occur NPE quite often. – Anti-X_KR Oct 04 '13 at 11:29
  • but now how should i switch back to the older version? – Sherry Oct 04 '13 at 11:31
  • If you didn't develop a lot yet, I recommend you to create new project on older eclipse instead of importing, exporting or something complicated... – Anti-X_KR Oct 04 '13 at 11:37
  • But nervermind, let's solve this on current version. So would you show me your 'activity_phonegap.xml'? I think something in there. – Anti-X_KR Oct 04 '13 at 11:38
  • i wont import or export any projects but even if i am creating a new project the gen folder is showing empty, and the software have been updated from SDK manager so now the current software if of updated version. – Sherry Oct 04 '13 at 11:41
  • alright. should i show it with xml editor? – Sherry Oct 04 '13 at 11:42
  • When android project created first, there is no R.java(also gen dir) in there. It will be created only when you clean(or build) at lease once. Please give me a moment to check xml. – Anti-X_KR Oct 04 '13 at 11:47
  • I'm sorry but i couldn't find anything in your xml. So please try to install older version of eclipse and create new project. – Anti-X_KR Oct 04 '13 at 12:37
0

The R.java file is autogenerated, follow these steps:

  • Make sure "Build automatically" is checked in the project menu
  • Go to project->clean...->clean your project
  • Make sure there is no errors in your xml files and clean again

If it still doesn't work, show me your imports

SiXoS
  • 535
  • 3
  • 14
0

The fact is that probably you're missing the Android Build tools. Or you just need to update them.

If you already updated the SDK tools, re-open the SDK manager and check under the "Tools" section that "Android SDK Build tools" are installed and eventually, update them. That made the trick for me yesterday.

Sanket Shah
  • 4,352
  • 3
  • 21
  • 41
0

It should be a problem with at least one of your resources files. Please do

Project -> Clean

Meanwhile look at the console window. It may indicating the problem's path.

enter image description here

If you are using a higher version of the android sdk. Just check whether have you installed the 'SDK build tools'.

enter image description here

and also check whether did you update necessary sdk packages and specially the android tools to the newest version.

enter image description here
(source: opencv.org)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
enadun
  • 3,107
  • 3
  • 31
  • 34
  • the problem is when i cleaned the projects the files which were present in the gen folder got disappeared :( dont know what has happened. – Sherry Oct 04 '13 at 11:18
  • When you clean the project, it will remove the R file from the gen folder and re checking the resources and re generate the R file. If a problem having with a resource file, the R file will not be generated. That's why R file is disappeared. – enadun Oct 04 '13 at 11:37
  • i regenerated the R file but the gen folder is showing empty – Sherry Oct 04 '13 at 11:45
  • Actually I am not getting any messages as such in the Console. All the projects i have done are full of RED crosses. – Sherry Oct 04 '13 at 11:54
  • First, Identify the error and fix it. Then the R file will be in the gen folder. – enadun Oct 04 '13 at 11:55
  • Yes, it contains bunch of red marks in the project. This will appear while you are cleaning the project. – enadun Oct 04 '13 at 11:57
  • yes it does, but the red marks are unable to disappear after that too. – Sherry Oct 04 '13 at 12:02
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/38614/discussion-between-enadun-and-sherry) – enadun Oct 04 '13 at 12:05
0

Follow the steps:

1) Make a clean of your project. 2) Close your project and open your project. 3) Close eclipse and restart. 4) Even if its not working then create a new project and place all Source and resource files from Earlier to this one.

This problem generally occurs when you update SDK manager but it's not permanent.

Suresh Sharma
  • 1,826
  • 22
  • 41
  • yep i did all these things. but still the project is not working fine. can u plz tell me how can i do to my previous version of the software? – Sherry Oct 07 '13 at 04:08
  • Are you using Windows System or Mac System or any else? – Suresh Sharma Oct 07 '13 at 07:23
  • Do you have jar files in your project. If yes then go to the properties->java build path-> Order an Export-> Check android private library. – Suresh Sharma Oct 07 '13 at 10:28