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.


当前回答

显然,在我的例子中,这个问题通过在结尾添加一个“*”得到了解决

import android.R.*;

其他回答

在我的情况下,原因是有一些图像在res文件夹名称包含一个大写字母..

只要用小写字母重新命名就可以了

清洁,重建和“缓存删除”不会帮助我,更新Android工作室修复了这个问题。

我自己也费了好大劲才搞定的。

确保layout.xml文件中没有错误。 转到构建>清洁项目

这招对我管用,希望对你也管用。

我受够了

我可绘制资源中的一个大写字母。 导入安卓。R由Android Studio(或Eclipse)添加 xml文件错误

这个符号看起来很好用。

android:id="@+id/viewID"

Android Studio的设计面板似乎不太好用。