简体   繁体   English

R.java自动删除:Android

[英]R.java deleted automatically: Android

When I changed some design in .xml file, R.java file automatically deleted. 当我在.xml文件中更改了一些设计时,R.java文件会自动删除。 How can I get back that file and what is the solution to resolve this problem, that in future this problem does not occure. 我怎样才能找回该文件以及解决此问题的解决方案是什么,以后这个问题不会发生。

check all your errors in xml files structure (layouts, string etc...) even if sometimes they are not easy to spot. 检查xml文件结构中的所有错误(布局,字符串等...),即使有时它们不容易被发现。

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 ) 一旦它们全部修复, R文件将再次创建(可能你需要清理你的项目: project -> clean

In the future just try not to break the xml files and this won't occur again xD 将来只是尝试不破坏xml文件,这将不再发生xD

修复你的错误,R.java文件将返回...例如,当我在我的资源文件夹中添加一个图像时,它的名称是大写....当我把它改成小写时,立即执行后我的R.java文件返回......一切都是由于错误......只需修复它们就会返回

You can also disable automatic build in your Eclipse IDE(Menu -> project- > Uncheck build automatically). 您还可以在Eclipse IDE中禁用自动构建(菜单 - >项目 - >自动取消选中构建)。 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. 这样,只有在手动构建项目时才会重新创建R文件,而不是在xml文件中保存更改时。

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. 一个解决方案是转到Eclipse项目选项卡 - >取消选中自动构建 - >清理项目。确保项目中没有错误,也不要尝试编辑它将创建的R.java文件。 Then manually build the project. 然后手动构建项目。 you will get the r.java file. 你会得到r.java文件。

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. Mac / Eclipse用户的最佳解决方案是转到SDK Manager并重新安装Android SDK Build-tools,然后重新启动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. 出于某种原因,在对项目执行清理操作后,所有项目的R.java文件都会从系统中删除。

Clean the project. 清理项目。

Menu [Project] -> [Clean...] -> Select you project -> [OK] Project will rebuild automatically, if not, chek Menu [Project] ->[Build Automatically] 菜单[项目] - > [清洁...] - >选择项目 - > [确定]项目将自动重建,如果没有,请单击菜单[项目] - > [自动构建]

I agree with @maid450. 我同意@ 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. 如果在完成所有这些问题后仍未解决问题,最终选项是创建一个新项目,并将文件复制到该项目。

The R file deleted automatically when I changed my activity_main.xml in Android Studio. 当我在Android Studio中更改activity_main.xml ,会自动删除R文件。

What I did was copy the R java file from another project and paste it into the project in which it got deleted. 我所做的是从另一个项目复制R java文件并将其粘贴到删除它的项目中。 Hope it helps. 希望能帮助到你。 :). :)。

Location for R file. R文件的位置。

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

Where is the R.java file in Android Studio? Android Studio中的R.java文件在哪里?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM