简体   繁体   English

android中带有R的gen文件夹中缺少包

[英]Missing package in gen folder with R in android

I have a problem with R in android. 我在Android中遇到了R问题。 I have a project with some packages. 我有一个包含一些软件包的项目。 I changed the name of one package. 我更改了一个包裹的名称。 I saw that the package with the same name was in "gen" folder. 我看到同名的程序包在“ gen”文件夹中。 When I changed the name, I cleaned the project and this package disappeared from "gen" folder. 更改名称后,我清理了项目,该包从“ gen”文件夹中消失了。 Now I have error with 现在我有错误

R cannot be resolved R无法解析

and in all classes I have errors with R. How I can repair my problem? 在所有课程中,我的R都有错误。如何解决我的问题?

So i think this is answer 所以我认为这是答案

Eclipse sometimes likes to add an "import android.R" statement at the top of your files that use resources, especially when you ask eclipse to sort or otherwise manage imports. Eclipse有时喜欢在使用资源的文件顶部添加“ import android.R”语句,尤其是当您要求eclipse排序或以其他方式管理导入时。 This will cause your make to break. 这将导致您的品牌受损。 Look out for these erroneous import statements and delete them. 查找这些错误的导入语句并将其删除。

Reference . 参考

And try to clean your project and if you have 并尝试清理您的项目,如果有

import android.R;

remove this line and clean it again. 删除这条线,然后再次清洁。

remove 去掉

import android.R;

and do Project > Clean... 并执行Project> Clean ...

Remove this import from your code if it is there. 如果导入已存在,则将其从您的代码中删除。

import android.R;

Clean your project and rebuild the solution again. 清理您的项目,然后重新构建解决方案。

If it isn't what the two other answers are, I've had a similar problem that related to me having an error in one of my XML files. 如果不是其他两个答案,那么我遇到了类似的问题,与我的一个XML文件中存在错误有关。 Since the XML file has an error, eclipse fails to build your project. 由于XML文件有错误,因此eclipse无法构建您的项目。 A failed build somehow messes up the path to the R.java file. 生成失败会以某种方式弄乱R.java文件的路径。 So if you clean up your XML files and build the project, it should fix itself. 因此,如果您清理XML文件并构建项目,它应该会自行修复。

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

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