刚才又遇到了R cannot be resolved to a variable的问题,就翻了翻网上的资料,调理的整理了一下
1. 检查Android 的SDK是否丢失需要重新下载,检查build path,把需要导入的JAR包确认都导入成功
2. 确保class没有import Android.R,注意是不能有Android.R,可以有其他R文件,比如你自己的包;
3. 错误class引用的layout的xml文件没有错误,经常是xml里面有错误,导致R文件无法正常生成
很多时候都是这个地方出错,可以尝试在layout 的xml文件手写添加一个控件,看id能否在R.java中自动生成,如果不能,那很大可能就是这个layout 的xml文件有问题,查看格式是否使用正确,或者包含什么非法字符串,或者调用到了不正确的字符串,等等,可以使用排除法,挨个去掉控件,直到发现error message消失或者id能在R.java中自动生成。记得以前经常因为android这个单词拼错而出现R文件无法正常生成而总是R
cannot be resolved to a variable
4. 检查AndroidManifest.xml文件,里边的package,layout配置文件,strings.xml等的字符串全部书写正确.
5.删掉gen文件夹,使R.java重新自动生成一次,如果不能生成,继续检查layout的xml文件是否有如上不易发觉的问题
6.Clean project ,重新build,或者重新import project。
7.重启eclipse
8.重启电脑,以防Android 虚拟机的问题
分享到:
相关推荐
> ★Http cannot be resolved to a variable > ★HttpEntity cannot be resolved to a type > ★EntityUtils cannot be resolved > ★HttpResponse cannot be resolved to a type > ★DefaultHttpClient cannot be ...
导入工程的“The import android cannot be resolved”错误解决方法
主要介绍了java eclipse 出现 xxx cannot be resolved to a type 错误解决方法的相关资料,需要的朋友可以参考下
测试类报错Test cannot be resolved to a type-附件资源
cocos The import com.loopj cannot be resolved 是缺失了jar包。导入lib文件夹,或者刷新eclipse就好了。
主要介绍了详解 问题:HttpServlet cannot be resolved to a type的相关资料,需要的朋友可以参考下
org.apache.commons.lang.exception.NestableRuntimeException cannot be resolved 解决 替换JAR包即可
jce.jar/jsse.jar解决The import javax.crypto cannot be resolved的问题
用于初学着 对错误提示的解释理解 提高学习速度 还还学习吧 希望对你有帮助
JSONObject cannot be resolved to a type 是因为缺少对应的依赖包:org-json.rar 包的来源github的项目:https://github.com/stleary/JSON-java中的Readme可以找到依赖包的地址。
解决The type org.springframework.dao.support.DaoSupport cannot be resolved.bao报错
rsslib4j-0.2.jar jar包,解决java报错找不到资源包问题 The import org.gnu cannot be resolved。 报错 import org.gnu.stealthp.rsslib.*; RSSChannel、RSSException、RSSHandler、RSSItem、RSSParser
ITextRenderer cannot be resolved to a type 错误就是因为缺少这个jar包
JSONObject所必须要用到的6个包,他们分别是commons-beanutils-1.7.0.jar、commons-collections-3.1.jar、commons-lang-2.5.jar、commons-logging.jar、ezmorph-1.0.3.jar、json-lib-2.1-jdk15.jar
Android NDK *** could not be resolved
JSTL 标签 发生 uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application问题时解决方法
NULL 博文链接:https://zuoqiang.iteye.com/blog/1337682
Word模板-授权委托书.wpt
The type org.apache.tools.ant.Task cannot be resolved. It is indirectly referenced from required .class files错误....., 解决办法:在工程中加入此jar包