In every instance in all of my classes where I reference R.id.something, the R is in red and it says "cannot resolve symbol R". Also every time there is R.layout.something it is underlined in red and says "cannot resolve method setContentView(?)". The project always builds fine. It is annoying to see this all the time. I have read many other questions on here about something similar but most involved importing projects from Eclipse. I am using what I believe to be the most recent version of Android Studio and the project was created with Android Studio and worked without any "cannot resolve R" problems. I would like to know what causes this if anyone knows.


当前回答

请看下面的图片去文件->项目设置->设置所有设置像图像和同步它将把所有最新的设置在你的项目。 如果您的项目导入成功,那么您必须这样做。因为它会导入所有的更新设置和gradle。

其他回答

这不是错误。 如果你有错误 关闭项目。 然后打开项目 在此之后,您可以得到一个错误

Cannot resolve symbol 'default_web_client_id'

可以通过在sting值中插入Web客户端ID来解决

我也遇到过同样的问题,当我创建一个新项目时,这种情况就会发生。

我所做的是:

检查SDK更新 然后是安卓工作室更新, 然后重新打开项目 打开andoridmanifest.xml 在android:标签中删除“_>”之间的空格并保存。

这对我很有用。

这些在Ubuntu 12.04上都不适用。我必须做到以下几点:

sudo apt-get install lib32stdc++6
sudo apt-get install lib32z1

在那之后,我遵循了这个线程中的其他一些建议,做了Build ->清洁项目,一切都很好。

我也有这个问题。简单的“gradlew clean”和“gradlew build”就成功了。


点击Build->Clean Project,将执行gradle Clean

“我也遇到过同样的问题,解决方法是:

1) Sync Project with gradle files
2) Build -> Clean Project
3) Build -> Rebuild Project
4) File -> Invalidate caches

//imp step
5) Check your xml files properly.`