R无法解析为变量? [英] R cannot be resolved to a variable?

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

问题描述

我清理了我的项目,现在我得到一个R无法解决变量。在我清理之前,这是很好的。



我已经尝试再次清理,再次构建项目,创建一个新项目并复制我的所有文件,去Android SDK Manager并安装所有的Android SDK Build-tools来安装所有其他stackoverflow帖子所提到的选项:



任何人都可以建议任何内容?





上图显示了我生成的文件和缺少一个R.java文件。





上图显示了我的问题日志。

解决方案

确保R与您要从中调用它的文件在同一个包中。
(或在源文件中导入包)



要更改R文件的包,请打开您的App Manifest文件,并将packge =更改为与您的源文件所在的软件包相同。




I cleaned my project and now I get a "R cannot be resolved to a variable." It was fine before I cleaned it.

I have tried cleaning it again, building the project again, creating a new project and copying all my files over, and I've gone to the Android SDK Manager and installed all the "Android SDK Build-tools" to Install all the options like the other stackoverflow posts have mentioned:

Can anyone suggest anything?

The above picture shows my generated files and lack of an R.java file.

The above picture shows my problems log.

解决方案

Make sure R is in the same package as the file where you want to call it from. (or import the package in the source file)

To change the package of the R file open your App Manifest file and change packge="" to the same package as where your source files are in.

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

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