Android Studio – Cannot resolve symbol ‘R’

Android Studio – Cannot resolve symbol ‘R

因要用到,所以最近学了点Android开发,用的编译器是亲儿子,也是新生儿 Android Studio。

今天在调试的时候,Android Studio 报了一个莫名其妙的错误Cannot resolve symbol 'R'让人不知所措。因为这东西根本不归我管啊,怎么会出现 Cannot resolve symbol 这种错误呢?

谷歌了一下,找到解决方法如下:

  • Build -> Clean Project
  • Tools -> Android -> Sync Project With Gradle Files

不行就多试几次!就好了!

原因是什么?估计是没自动生成 R.java 文件。为什么会出现这样的问题?因为Android Studio是新生儿。。。。

再来看看一位遇到过此问题的网友的内心独白!Just For Fun!^_^

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 however never fails to build and does work fine. It is just 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.

UPDATE: Please accept my apologies for never updating this. I solved my own problem since this has been posted. At the time android studio was brand new and I was also a brand new developer. I should never had been using android studio, I never realized how unfinished it was. Thanks everyone for the support in trying to help since this has been posted. Ironically the actual “answer” to this question has been deleted and cannot be undeleted. I feel that my original answer is the solution to this problem, in short don’t use android studio if you are new to android development.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值