"Unable to resolve symbol R" in Android Studio

This article was translated from: "cannot resolve symbol R" in Android Studio

Want to improve this post? Want to improve this post ? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Provide detailed answers to this question, including citations and explanations of why the answers are correct. Answers without enough detail may be edited or deleted. Answers without enough detail may be edited or deleted .

In every instance in all of my classes where I reference R.id.something, the Ris in red and it says "cannot resolve symbol R". In R.id.somethingall instances of all classes I reference , it Ris red and displays "Cannot resolve symbol R". Also every time there is R.layout.somethingit is underlined in red and says "cannot resolve method setContentView (?)". Similarly, every time R.layout.somethingit is underlined with red underline means "cannot resolve method setContentView (?)". The project always builds fine. The project can always run normally. 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 read many other questions here that are related to similar but most related to 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 am using the latest version of Android Studio that I believe is, and the project It was created using Android Studio and can work normally without any "unable to solve R" problem. I would like to know what causes this if anyone knows. If someone knows, I want to know what caused it.


#1st Floor

Reference: https://stackoom.com/question/19YWW/Android-Studio-Unable to resolve symbol R


#2nd Floor

Have you updated your SDK tools recently? Have you updated your SDK tools recently ? Launch the android SDK manager and make sure you have the latest SDK tools, which is now separate from the platform tools. Launch the android SDK manager and make sure you have the latest SDK tools, which are now separate from platform tools . I had this same issue when I first updated my SDK manager, the SDK build tools package did not show up for install / update until I closed and reopened the SDK manager. I had the same problem when I first updated my SDK Manager, the SDK build kit did not appear to be installed / upgraded until I closed and reopened the SDK manager.


#3rd floor

I had the same problem, and it happens when I create a new project. I had the same problem, and it happened when I created a new project.

What I do is: What I want to do is:

  • check for SDK updates check SDK update
  • then android studio updates, then android studio updates,
  • then reopen the project and then reopen the project
  • open the andoridmanifest.xml Open andoridmanifest.xml
  • erase a space between a "_>" in the android: label and save. Delete the space between "_>" in android: label and save .

That works for me. This works for me .


#4th floor

This notation seems to work fine. This notation seems to work fine .

android:id="@+id/viewID"

Android Studio's design panel doesn't seem to work well. Android Studio's design panel doesn't seem to work properly.


#5th Floor

I had this this issue too. I also had this issue. A simple 'gradlew clean' and 'gradlew build' did the trick. A simple "gradlew clean" and "gradlew build" can solve the problem.


Click on Build->Clean Project and that will perform a gradle clean 点击Build- > Clean Project ,这将执行gradle clean


#6th floor

I have had this with me have this

  1. An uppercase letter in my drawable resources. An uppercase letter in my drawable resources .
  2. Import Android.R being added by Android Studio ( or Eclipse) introduced android.R added by Android Studio (or Eclipse)
  3. In xml File Error xml file errors
Published 0 original articles · praised 75 · 560,000 views +

Guess you like

Origin blog.csdn.net/w36680130/article/details/105482564