R.java deleted automatically: Android

When I change some design in the .xml file, the R.java file is automatically deleted. How can I return this file and what is the solution to this problem that this problem does not occur in the future.

+4
source share
8 answers

You can also disable auto-build in your Eclipse IDE (Menu → project-> Unassemble automatically). Thus, the R file will be recreated only when the project is manually assembled, and not when the changes are saved in the XML file.

+4
source

check all your errors in the structure of xml files (layouts, line, etc.), even if they are sometimes not easy to detect.

My advice is to undo the last steps you performed until you find where the errors were and correct them.

After all of them are fixed, the R file will be created again (maybe you need to clean the project: project -> clean )

In the future, just try not to break the xml files, and that won't happen again xD

+5
source

Correct your mistakes and the R.java file will return ... for example, when I added the image to my resources folder, its name was in upper case ... when I changed it to lower case, right after its execution R. java file is back ... it's all due to mistakes ... just fix them and he will be back

+4
source

I agree with @ maid450.

I also encountered similar situations.

If your problem is not solved after all this, the final option is to create a new project and copy the files to it.

0
source

one solution is to switch to the project tab Eclipse → uncheck Build Automatically → Clear Project. Make sure that there is no error in your project and do not try to edit the R.java file that it will create. Then manually create the project. you will get the r.java file.

0
source

The best solution for the Mac / Eclipse user is to switch to the SDK manager and reinstall the Build-tools SDK, and then restart Eclipse.

For some reason, after the "Clear" action is performed in the project, the R.java file for all projects is deleted from the system.

0
source

Clean up the project.

[Project] menu → [Clear ...] → Select a project → [OK] The project will be rebuilt automatically, if not, chek [Project] menu → [Automatically create]

0
source

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

I copied the Java R file from another project and pasted it into the project in which it was deleted. Hope it helps. :).

File Location R

Project/app/build/generated/source/r/debug/com.android.'projectname'/R.java

Where is the R.java file located in Android Studio?

0
source

Source: https://habr.com/ru/post/1334346/


All Articles