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.
当前回答
只需进入Android Top菜单列表。点击构建菜单,在构建下点击重建项目。
其他回答
我也有这个问题。简单的“gradlew clean”和“gradlew build”就成功了。
点击Build->Clean Project,将执行gradle Clean
我发现在大型项目中,自动生成的R.java大于2.55MB (Intellij的默认限制),这导致文件生成但无法解析。要解决这个问题,只需提高极限:
在Android Studio帮助->编辑自定义属性…
接受并添加以下内容: idea.max.intellisense.filesize = 3000 (3000或任何大于R文件大小的值)
最后,重启你的Android Studio!
我受够了
我可绘制资源中的一个大写字母。 导入安卓。R由Android Studio(或Eclipse)添加 xml文件错误
Build ->清理项目或重建项目 或 File -> Invalidate cache / Restart…->失效并重启
我已经做了其他答案中提到的所有步骤,但它仍然没有得到解决。我正在使用android工作室花栗鼠,最后我能够通过删除来解决这个问题
maven { url "https://jitpack.io" }
从设置。gradle我在回答这个问题,我认为这样做可能会帮助到一些人
推荐文章
- BottomSheetDialogFragment的圆角
- 在应用程序启动时出现“无法获得BatchedBridge,请确保您的bundle被正确打包”的错误
- 我如何改变默认对话框按钮的文本颜色在安卓5
- 更改单选按钮的圆圈颜色
- 如何在android中复制一个文件?
- adb找不到我的设备/手机(MacOS X)
- Android Studio中的。iml文件是什么?
- 如何在新的材质主题中改变背面箭头的颜色?
- androidviewpager与底部点
- 相同的导航抽屉在不同的活动
- 如何从视图中获得托管活动?
- 单一的TextView与多种颜色的文本
- 如何在非活动类(LocationManager)中使用getSystemService ?
- 在清单中注册应用程序类?
- Android:从数组中编程创建旋转器