`

cannot be resolved to a variable 解决办法

 
阅读更多
 cannot be resolved to a variable 解决办法
 
Android开发过程中,碰到R cannot be resolved to a variable的报错信息,好像没有很确定的错误原因,一般来说,我总结出几个可能的解决方法,希望试过以后管用。。。

1. 检查Android 的SDK是否丢失需要重新下载,检查build path
2.确保class没有import Android.R;
3,错误class引用的layout的xml文件没有错误
4.检查AndroidManifest.xml文件,里边的package,layout配置文件,strings.xml等的字符串全部书写正确
5.layout的xml文件中引用的strings.xml中的字符串拼写完全正确
6.在layout 的xml文件手写添加一个控件,看id能否在R.java中自动生成,如果不能,那很大可能就是这个layout 的xml文件有问题,查看格式是否使用正确,或者包含什么非法字符串,或者调用到了不正确的字符串,等等,可以使用排除法,挨个去掉控件,直到发现error message消失或者id能在R.java中自动生成。
7.删掉gen文件夹,使R.java重新自动生成一次,如果不能生成,继续检查layout的xml文件是否有如上不易发觉的问题
8.Clean project ,重新build,或者重新import project。
9.重启eclipse
10.重启电脑,以防Android 虚拟机的问题
分享到:
评论

相关推荐

    httpcomponents-client-4.5.5-bin和src_20180518.zip

    > ★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 ...

    variable name cannot be resolved(解决方案).md

    variable name cannot be resolved(解决方案).md

    java错误提示英汉对照

    - **Pattern范式、模式、样式**:指的是一种解决常见问题的模板或者指导原则,在设计模式中尤为常见。 #### 二、编程术语对照与解释 接下来,我们将对文档中提到的一些术语进行详细的对照和解释: ##### - 类别与...

    Git-2.21.0-64-bit.zip

    * "git am -i --resolved" segfaulted after trying to see a commit as if it were a tree, which has been corrected. * "git bundle verify" needs to see if prerequisite objects exist in the receiving ...

    微软内部资料-SQL性能优化3

    In a multigranular locking environment, there must be a way to effectively overcome this scenario. Intent lock is the answer to this problem. Intent Lock Intent Lock is the term used to mean placing ...

    android开发环境安装说明

    - **问题三**:“R cannot be resolved to a variable” - 解决方案:检查SDK的安装路径是否包含`platform-tools`目录,必要时重新解压相关ZIP文件。 通过以上步骤,你将成功搭建一个完整的Android开发环境,准备...

    Delphi7.1 Update

    * A TLargeIntField cannot be used as a linking field in a master/detail relationship. Doing so results in the error "Cannot access field <fieldname> as type variant." * TClientDataSet doesn...

    acpi控制笔记本风扇转速

    The disassembler now emits a comment if a buffer appears to be a ResourceTemplate, but cannot be disassembled as such because the EndTag does not appear at the very end of the buffer. AcpiExec - ...

    java-rythmengine-variable-name-org-issue-demo

    Exception in thread "main" org.rythmengine.exception.CompileException: rythmengine cannot be resolved or is not a field Template: src/main/resources/rythm/hello.rythm Relevant template source lines: ...

    Ubuntu搭建Eclipse+JDK+SDK的Android开发环境

    - "R cannot be resolved to a variable"错误通常是由于项目构建问题,尝试清理项目(`Project > Clean`),或手动删除`gen`和`bin`目录,Eclipse会自动生成新的`R.java`文件。 完成以上步骤后,你已经在Ubuntu上...

Global site tag (gtag.js) - Google Analytics