在Eclipse中,我从源代码创建了一个项目,现在它显示了错误——“R不能被解析为变量”。从我在这里找到的,我已经清除和重建了项目,但R文件仍然没有出现在/gen文件夹中。
什么好主意吗?
在Eclipse中,我从源代码创建了一个项目,现在它显示了错误——“R不能被解析为变量”。从我在这里找到的,我已经清除和重建了项目,但R文件仍然没有出现在/gen文件夹中。
什么好主意吗?
当前回答
当没有遵循android命名约定时,就会发生这种情况。检查你是否在android文件夹中放置了一个文件/照片,并确保文件名只包含小写字母
其他回答
对我来说,通过在Android SDK管理器中进行一些更改,这个错误得到了修复。 无论最新的API级别是什么,安装它的“SDK平台”。对我来说,最新可用的API级别是16,所以我安装了它的SDK平台,如下图所示。现在可以正常工作了。
干杯,玛雅克
在我的情况下,R.java没有被生成,因为一个分层的父错误,这反过来被更新了一个或多个Eclipse插件(Go Eclipse—>Help—>Check for Updates)所修复。
尝试修改AndroidManifest文件。
例如,添加空格并删除此空格。操作完成后,保存项目。刷新资源。这是有帮助的。
我的设置在最近的更新后被打破,其中SDK构建工具需要在SDK安装后单独安装。所以构建工具更新+ Eclipse重新启动为我修复了这个问题。
信用归于这里的Android回复
对我来说,建议那些对“R”文件有问题的人的最佳解决方案是尝试以下步骤(顺序不重要):
update ADT & SDK , Eclipse and Java. remove gen folder , and create it again . do a clean-project. right click the project and choose android-tools -> fix-project-properties . right click the project and choose properties -> java-build-path -> order-and-export. make sure the order is : Android 4.3 (always the latest version) Android private libraries android dependencies your library project/s if needed yourAppProject/gen yourAppProject/src make sure all files in the res folder's subfolders have names that are ok : only lowercase letters, digits and underscore ("_") . always make sure the targetSdk is pointed to the latest API (currently 18) , and set it in the project.properties file