Eclipse 错误:R 无法解析为变量 [英] Eclipse error: R cannot be resolved to a variable

查看:33
本文介绍了Eclipse 错误:R 无法解析为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Eclipse IDE 中遇到了这个经典错误.我对 Eclipse 的错误感到厌烦.他们把我逼疯了.

I am getting this classic error in Eclipse IDE. I am bored of Eclipse's bugs. They driving me mad.

我几乎尝试了所有建议的解决方案(通过谷歌搜索).他们都没有工作.

I almost tried everything which suggested as solution (by Googling). None of them worked.

我的项目工作正常,但代码没有变化.

My project was working normally but not code changes.

我看到我的代码更改没有对我的应用程序起作用(在 AVD 上),然后我清理了我的项目(在 Project > Clean... 下).R.java 文件不见了,res 文件夹是空的.

I see that my code changes does not acting on my app (on AVD) then I cleaned my project (under Project > Clean...). R.java file was gone and res folder was empty.

现在我收到那个错误:R 无法解析为变量.

我该怎么办?

而且我还尝试删除项目并使用我之前备份过的Android Project from Existing Code 重新创建.清洁后它已经给出了同样的错误.

And also I tried to delete project and create again with Android Project from Existing Code I've backed-up before. It already gives same error after cleaning.

任何想法将不胜感激.

推荐答案

我假设您已将 ADT 更新为 22 版并且未生成 R.java 文件.

I assume you have updated ADT with version 22 and R.java file is not getting generated.

如果是这种情况,那么这里是解决方案:

If this is the case, then here is the solution:

希望你知道 Android Studio 有 gradle 构建工具.与在 Eclipse 中相同,他们在 Tools 文件夹中提供了需要安装的名为 Android SDK Build-tools 的新组件.打开Android SDK Manager,选择新添加的构建工具,安装,更新后重启SDK Manager.

Hope you know Android studio has gradle building tool. Same as in eclipse they have given new component in the Tools folder called Android SDK Build-tools that needs to be installed. Open the Android SDK Manager, select the newly added build tools, install it, restart the SDK Manager after the update.

这篇关于Eclipse 错误:R 无法解析为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆