R.java deleted automatically: Android

When I changed some design in .xml file, R.java file automatically deleted. How can I get back that file and what is the solution to resolve this problem, that in future this problem does not occure.


You can also disable automatic build in your Eclipse IDE(Menu -> project- > Uncheck build automatically). This way the R file will be recreated only when you manually build the project and not when you save changes in an xml file.

check all your errors in xml files structure (layouts, string etc...) even if sometimes they are not easy to spot.

My advice is to undo the latest things you've done until you find where the errors were and fix them.

Once they are all fixed the R file will be created again (maybe you need to clean your project: project -> clean)

In the future just try not to break the xml files and this won't occur again xD

Fix your errors and the R.java file will return...e.g when i added an image in my resources folder its name was in uppercase....when i changed it to lowercase,immediately after doing it my R.java file returned...its all due to errors...just fix them and it will return

I agree with @maid450.

I also have faced similar situations.

If your problem isn't resolved after all this, ultimate option is to create a new project, and copy files to it.

one solution is that Go to Eclipse project tab -> uncheck Build Automatically -> Clean the project.Make sure that there is no error in your project also don't try to edit the R.java file one it will created. Then manually build the project. you will get the r.java file.

The best solution for Mac/Eclipse user is to go to the SDK Manager and re-install the Android SDK Build-tools, and then restart Eclipse.

For some reason after performing a Clean action on a project the R.java file for all projects happens to be deleted from the system.

Clean the project.

Menu [Project] -> [Clean...] -> Select you project -> [OK] Project will rebuild automatically, if not, chek Menu [Project] ->[Build Automatically]

The R file deleted automatically when I changed my activity_main.xml in Android Studio.

What I did was copy the R java file from another project and paste it into the project in which it got deleted. Hope it helps. :).

Location for R file.


Where is the R.java file in Android Studio?

Need Your Help

Wordpress editor not working with custom widget

wordpress widget editor

i have create come script for Add Wp-Editer it's working fine in other place but not working in Widget and Page Builder by SiteOrigin please help me...

How to enable auto-complete in Emacs Org-babel?

emacs autocomplete org-mode babel

I would like to enable auto-complete for Babel code blocks in org-mode: