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.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Just go to Android Top menu list. click on Build Menu, in under Build click on Rebuild Project.
I had the same problem, and it happens when I create a new project.
What I do is:
That works for me.
Just clean your project and Sync Project with Gradle File.
And the problem will be resolved.
This is it.
For example I had an entry in my
strings.xml
:And in
activity_main.xml
I used this string entryWhile'd been working with project, I deleted that
And consequently
activity_main.xml
became not valid. As the result: cannot resolve R.So, check your
*.xml
files and clean project.I had a hard time fixing this myself.
It worked for me, hope it works for you too.
change the latest sdk version,that was work for me
1.Click file and then click project structure 2.then select "app" then click ok,its worked for me.