Solve the problem of Android Studio error: Cannot resolve symbol 'xxx'

Preface talk

I encountered a strange problem today:

Like most developers, as usual, I turned on my computer and opened Android Studio to build an existing project and prepare to continue development. Today, after the construction was completed, suddenly some pseudocode (comments), data types, etc. were marked red, and I was confused. I doubted my life for a while. Could it be that my opening posture was wrong? Or is it a company where I step in with my left foot first?

Now that the problem has arisen, let’s find a way to solve it: I first compiled the project, hoping to solve the problem, and no errors were reported. The compilation passed, passed, passed... Nani? I have a bit of obsessive-compulsive disorder and I feel uncomfortable watching the screen turn red. I keep looking for a way!

 

Solve the problem

I checked the settings of AndroidStudio. The paths to JDK, SDK, etc. are all correct and there are no problems.

Then I searched around and found that most of the solutions on the Internet were solved by the following methods, but they did not solve my problem:

1. Use Invalidate Caches/Restart to clear AndroidStudio’s cache

2. Use Clean Project to clean AndroidStudio’s compiled files

3. Reload the Gradle file

 

My final solution:

Hovering the mouse over the red words such as @Override, I found that the SDK needs to be setup, which means that the SDK package has not been imported, but I have already set it up, and the compilation has passed, which is strange!

Then press alt+enter, select the corresponding SDK package to import, and the problem is solved!

 

I hope it can help everyone. If you like it, you can click and follow!

 

Guess you like

Origin blog.csdn.net/Cy_Shay/article/details/92767428